stream-parser icon indicating copy to clipboard operation
stream-parser copied to clipboard

Child nodes not returned in query

Open Lexmark-gudeguzman opened this issue 5 years ago • 1 comments

If I have this in XML:

<strings>
<textitem type="COMPLEX" textID="TXT_RELOAD_PRINTED_PAGES_IN_SOURCE" translated="YES" description="IR header string. This will be used for IR for inserting duplex pages. The source tag will be replaced by the requested paper source.">
    <context contextID="TX_CONTEXT_2x16">
      <subcontext abbrevFlag="UNKNOWN" maxLines="4" subcontextID="TX_SUBCONTEXT_DEFAULT" prefFontSize="16" maxPels="25">
        <text><![CDATA[Reload printed pages<br/>in <source/>]]></text>
      </subcontext>
    </context>
    <context contextID="TX_CONTEXT_4x20">
      <subcontext abbrevFlag="UNKNOWN" maxLines="2" subcontextID="TX_SUBCONTEXT_DEFAULT" prefFontSize="16" maxPels="160">
        <text><![CDATA[Reload printed pages<br/>in <source/>]]></text>
      </subcontext>
    </context>
  </textitem>
</strings>

And does: StreamParser::xml($request->fileUrl)->each(function(Collection $item) { var_dump($item); });

Only the last <context> node is returned.

Lexmark-gudeguzman avatar May 24 '19 02:05 Lexmark-gudeguzman

I wasn't expecting this behaviour either. Utilising withoutSkippingFirstElement() gave me the results I required, e.g. as per your example:

StreamParser::xml($request->fileUrl)->withoutSkippingFirstElement()->each(function(Collection $item) {
  var_dump($item); 
});

kimobot avatar Sep 30 '19 07:09 kimobot