XML Parse problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ctrLogicDotNet
Forum Newbie
Posts: 24
Joined: Fri Jul 24, 2009 10:52 am

XML Parse problem

Post by ctrLogicDotNet »

Hi,
I'm having troubles parsing an XML file...

Would have liked to use simpleXML as I'm used to, but it's not working cause I have attributes in a parent node...

Looked at XmlParser, not sure that the information I've read is enough to throw myself into it...

Here's my XML file:

Code: Select all

 
<?xml version="1.0" encoding="UTF-8"?>
<first_node>
    <child_lvl_one attr="">
        <child_lvl_two attrone="" attrtwo=""/>
    </child_lvl_one>
</first_node>
<second_node>
    <child_lvl_one>
        <child_lvl_two attrone="" attrtwo=""/>
    </child_lvl_one>
</second_node>
 
ctrLogicDotNet
Forum Newbie
Posts: 24
Joined: Fri Jul 24, 2009 10:52 am

Re: XML Parse problem

Post by ctrLogicDotNet »

Wow I've retried this with simpleXml and it seems to work...
Don't know what went wrong...
Sorry for those questioning themselves about this issue

Still Thank You for answers and post any comments about similar problems if they occur
ctrLogicDotNet
Forum Newbie
Posts: 24
Joined: Fri Jul 24, 2009 10:52 am

Re: XML Parse problem

Post by ctrLogicDotNet »

My problem was that one of my parents attribute had an & (ampersand) character...
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: XML Parse problem

Post by requinix »

ctrLogicDotNet wrote:My problem was that one of my parents attribute had an & (ampersand) character...
Then it should be escaped as & otherwise it's assumed to be the beginning of an entity (like &nbsp; or &#1234;).
If it's not escaped it could make the XML invalid.
Post Reply