1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to parse incomplete XML body using libxml/SAX or any other parser

Discussion in 'C' started by praveenss, Jan 13, 2009.

  1. praveenss

    praveenss New Member

    Joined:
    Jan 13, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have to write a program where we get the xml file incrementally. i.e the file is constantly updated in the form of xml feed. Thus the first chunk will not be a well formed xml document. However i need to parse the feeds regularly and display the parsed result.

    How can this be achieved.?

    Eg...

    xml field can be following

    First chunk is as follows: We can see it is not well formed
    <xml>
    <results>
    <result1>
    </result1?
    <result2>
    </result2>


    The next chunk will be

    <result3>
    </result3>
    <result4>
    </result4>
    </results>
    </xml>



    Please help!! I would be greatful if you could provide me with sample code or some links which i can follow.

    TIA
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Any parser is going to be based on you having the complete XML, so if you don't want to write your own you will need to collect the chunks until you have the complete document, then you can squirt the data into your preferred parser.

    Or you can write your own parser that will process a partial document. Parsing XML isn't a particularly difficult thing to do.
     

Share This Page