"Non-standard" xml file parsing...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi all,

        I used simplexml_load_file function to parse all my xml feeds,
and found it to be the easiest option available. But, i recently
signed up for a feed which sends the xml file without the first
mandatory line, i.e, <?xml version="1.0" encoding="ISO-8859-1" ?>....
       I learned that simplexml_ does not parse without the above
line, is this true, if yes, is there a way to add the above line once
retrieving the contents and passing it to simplexml_ function.
       PLEASE HELP, I don't want to parse using good old dom or other



Re: "Non-standard" xml file parsing...

Harsha schreef:
Quoted text here. Click to load it

sure, the most simple way is to store that 1 line in a file i.e. named

and than do this on your system:
$ cat head.xml input.xml > xmlwithhead.xml


Re: "Non-standard" xml file parsing...

Quoted text here. Click to load it

Thanks, I resolved the problem....

Re: "Non-standard" xml file parsing...

Quoted text here. Click to load it

It might be an idea to file a complaint with the provider of the
feed.  If it's missing the header then it's not a valid XML feed and
XML parsers are under no obligation to attempt to parse malformed

Site Timeline