Hi all, I have an xml file like this: <container> <item> <val1>Some val</val1> <val2></val2> <val3>some other val</val3> <val4>And yet another</val4> </item> </container> Code (markup): There are hundreds of items. What is the simplest functions to use to parse this so that i can get the values of <val1> and <val4> Im happy to go read the manual but i hoped someone might point me in the right direction to get me started? thanks... Nick
Assuming your XML document is in the variable $data... $parser = xml_parser_create('UTF-8'); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); PHP: That will leave you with two arrays ($vals and $index) that will give you everything you need.
>>xml_parse_into_struct it all comes flooding back.. sheesh i have no memory, i actually did somthing similar once lol! The only thing now is to try and get my head around the two array thing, i remember that being a real headache! thanks shawn, very much obliged mate Nick
If you have PEAR installed you can use the XML_SERIALIZER package. You can get a XML file into an array and work with the array as you like. I can provide yo uwith an example and I think you can find tutorials in the web.
there are some tutorials i saw online, if you cnt find the answer here (and sry i cnt help u ) i would suggest you search yahoo or google