Re: How can I load this XML file into an array? (and. . . how do I reference the values?)
| From: | John A DAVIS | Date: | Fri, 26 Oct 2007 23:51:06 +0000 |
| Subject: | Re: How can I load this XML file into an array? (and. . . how do I reference the values?) | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263742@lists.php.net to get a copy of this message | ||
simplexml won't work for our version of PHP. planning on upgrading once we get the new server
>>> "mike" <mike503@gmail.com> 10/26/2007 4:42:09 PM >>>
On 10/26/07, John A DAVIS <John.A.Davis@state.or.us> wrote:
>
>
> this works:
> $xml_data = file('xml_edwr2.xml');
> var_dump($xml_data);
>
> I can get the var_dump to work for 1 sample, but I guess there are a many
> samples in one xml file which turns into something like this(so, there is no
> way for me to reference a "column"):
>
the code came out horribly in email, but you should be able to use
xpath-y type stuff to access it.
i.e.
foreach($sxml->node->childnode as $node) {
now you are in a foreach loop on this level
}
simplexml is great for quick parsing of well-formed XML.
there's also DOM functions, PEAR libraries, and of course XSLT to try
to get the XML into an easier to use format... but I typically try to
use built in stuff when possible :)