"Non-standard" xml file parsing...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harsha

    "Non-standard" xml file parsing...

    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
    techniques.....

    Thanks...

    -Harsha
  • Luuk

    #2
    Re: &quot;Non-standard&quot; xml file parsing...

    Harsha schreef:
    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
    techniques.....
    >
    Thanks...
    >
    -Harsha
    sure, the most simple way is to store that 1 line in a file i.e. named
    head.xml

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



    --
    Luuk

    Comment

    • Harsha

      #3
      Re: &quot;Non-standard&quot; xml file parsing...

      On Jul 26, 1:28 pm, Luuk <L...@invalid.l anwrote:
      Harsha schreef:
      >
      Hi all,
      >
              I used simplexml_load_ file function to parse all my xmlfeeds,
      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 orother
      techniques.....
      >
      Thanks...
      >
      -Harsha
      >
      sure, the most simple way is to store that 1 line in a file i.e. named
      head.xml
      >
      and than do this on your system:
      $ cat head.xml input.xml xmlwithhead.xml
      >
      --
      Luuk
      Thanks, I resolved the problem....

      Comment

      • Gordon

        #4
        Re: &quot;Non-standard&quot; xml file parsing...

        On Jul 26, 6:33 am, Harsha <harsha1...@gma il.comwrote:
        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
        techniques.....
        >
        Thanks...
        >
        -Harsha
        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
        XML.

        Comment

        Working...