- vs _ with simplexml_load_file()

I am trying to parse an xml file, the parent and children use - instead of _ which I'm used to.


I have been using simplexml_load_file() to parse past xml files and putting it through a foreach() loop to echo everything back out.

$xml = simplexml_load_file($url);

foreach($xml->the-parent as $parent) {
   echo $parent->the-children;

I keep getting this error Warning: Invalid argument supplied for foreach()

I can't change the format of the xml file because I am getting it from a 3rd-party. What are my options for parsing this correctly?


You can do something like $xml->{'the-parent'}.

See example #3: http://www.php.net/manual/en/simplexml.examples-basic.php

You can use $x->{'the-parent'} and $parent->{'the-children'} to access those values.

Need Your Help

How to initialize a string with a fill pointer in Common Lisp?

string format common-lisp fill-pointer adjustable-array

I want to use formatted output in a loop to generate a string. Manual says it can be easily done by giving format function a string with a fill pointer as a destination. Unfortunately, it is not

JQM phonegap.js android app breaks app view? why?

jquery android mobile

I have been using phonegap.js with jqm to built a mobile android app. I have the index.html doing a redirect to the mobile page its directed too. The app stays within the 'app view' aka full scr...