homepage Welcome to WebmasterWorld Guest from 23.22.173.58
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
SimpleXML drops inline tags?
EvertVd



 
Msg#: 4442849 posted 8:24 am on Apr 19, 2012 (gmt 0)

Suppose you have an xml-file with the following structure (taken from the php manual):

<movie>
<title>PHP: Behind the Parser</title>
<plot>
So, this <o>language</o>. It's like, a programming language. Or is it a
scripting language? All is revealed in this thrilling horror spoof
of a documentary.
</plot>
</movie>


I made one change to this code as opposed to the original, I added an <o> 'inline' tag as child of <plot>.

When I use this xml to create a SimpleXML Element the node 'plot' drops this <o> tag and it's contents (<o>language</o>. Is there anyway to either keep the tag or at least its contents?

 

enigma1

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4442849 posted 11:34 am on Apr 19, 2012 (gmt 0)

That's because you don't want the string of plot to be parsed by the XML as it is html, so one way is to use the CDATA because you don't want it to be interpreted as markup

<plot>
<![CDATA[
So, this <o>language</o>. It's like, a programming language. Or is it a
scripting language? All is revealed in this thrilling horror spoof
of a documentary.
]]>
</plot>

or you encode the characters like &lt; &gt; etc.

EvertVd



 
Msg#: 4442849 posted 12:22 pm on Apr 19, 2012 (gmt 0)

Bummer. The problem is I have no control over the xml. I will be getting large amounts of files with this type of markup which I need to parse :-(

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved