fast_xml icon indicating copy to clipboard operation
fast_xml copied to clipboard

Streaming elements not directly below the root

Open lpil opened this issue 7 years ago • 3 comments

Hello! First, thank you for this library. I'm very happy with the performance improvement over xmerl.

I have a large XML document I wish to stream, it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<tns:Envelope xmlns:tns="urn:Service:Integration">
  <tns:Body>
    <tns:RangeResponse>
      <tns:RangeResult>
        <tns:Detail> ...more content here... </tns:Detail>
        <tns:Detail> ...more content here... </tns:Detail>
        <tns:Detail> ...more content here... </tns:Detail>
        <tns:Detail> ...more content here... </tns:Detail>
        <tns:Detail> ...more content here... </tns:Detail>
        <tns:Detail> ...more content here... </tns:Detail>

        ... and so on...

      </tns:RangeResult>
    </tns:RangeResponse>
  </tns:Body>
</tns:Envelope>

I wish to process each Detail element in turn, getting messages like so:

{'$gen_event', {xmlstreamelement, {xmlel, "Detail", [], ...}}}

However when I stream this document by passing each line to fxml_stream:parse/2 I get a single message containing the Body element, meaning I am parsing and processing the Detail elements eagerly.

Is it possible to instruct fast_xml to use RangeResult as the root?

Thanks, Louis

lpil avatar Jan 31 '18 13:01 lpil

No, this is not configurable at this moment

prefiks avatar Jan 31 '18 14:01 prefiks

Thank you

lpil avatar Jan 31 '18 14:01 lpil