Re: Parsing an XML return from a POST - resend with a little more information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Luckhurst wrote:
> Hi Jochem,
> 
> Thanks for your reply. Here is a short sample of the XML I have to parse. I need
> the data in the attributes as well as the data in the character fields.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <?ypsilon RNGSchema="fareResponse.rnc" type="compact"?>

I'm fairly certain that this 'ypsilon' tag is going to cause a
problem - although that's just a guess, it's based on the 'knowledge'
that a valid XML document *must* have only 1 root element
(which would be 'fareResponse' in this case).

you might have to use preg_replace() to strip this 'ypsilon' tag
from you xml stgring prior to feeding it into simpleXML (or other
XML parser).

e.g. something *like*:

$xml = preg_replace('#<\?ypsilon .*\?>#', '', $xml);

> <fareResponse cntTarifs="122" offset="0">

...

> </fareResponse>
> 
> 
> 
> 
> JM> me, I'm pretty convinced simpleXML is what he wants.
> 
> JM> simpleXML was a dog to use in earlier versions of php5 because simpleXML objects
> JM> were 'immune' to inspection by var_dump(), print_r(), etc [meaning you be told some
> JM> property was an array and then get an error if you access said property as an array,
> JM> stuff like that].
> 
> JM> those problems have been helped the way of the dodo so now simpleXML really does
> JM> what it says on the tin.
> 
> JM> of course there is always the options of using regular expressions or simple
> JM> string manipulation functions to extract the relevant data from the string of
> JM> 'xml' - technically there is no need to go anywhere near a 'real' xml parser
> JM> as such.
> 
> So far I have had no luck with simpleXML at all.

do as Roman says and post the simpleXML code you have so far.

> 
> Regards
> 
> Richard Luckhurst
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux