frobak Posted August 3, 2012 Share Posted August 3, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/266651-accessing-simple-xml-elements/ Share on other sites More sharing options...
cpd Posted August 4, 2012 Share Posted August 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266651-accessing-simple-xml-elements/#findComment-1366765 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.