Jump to content

Accessing simple XML elements


frobak

Recommended Posts

Hey

 

Right, have this issue with accessing simpleXML elements, i'm sure it should work, but i cant seem to get it.

 

This is the xml data. I need the model and make:

<diffgr:diffgram>
<NewDataSet>
<StdData diffgr:id="StdData1" msdata:rowOrder="0">
<MAKE>CITROEN</MAKE>
<MODEL>C3 SX</MODEL>

 

here is the php ive got:

$xml->children("diffgr", true)->diffgram->children("")->NewDataSet->StdData->MAKE;

 

Can you see where im going wrong?

 

cheers

Link to comment
Share on other sites

Your XML looks invalid. You have no namespace definition and do not close the diffgram, NewDataSet or StdData tags.

 

Once its valid you can retrieve the make and model using

 

$xml->children('diffgr', true)->children()->MAKE;
$xml->children('diffgr', true)->children()->MODEL;

 

Although that code is dependent on how you close your XML tags. You may need another step in there because of your NewDataSet which I see no need for at the minute.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.