function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
inbaljS2inbaljS2 

How do I read a XML document with branches/children

Hi all,

I need to read an XML document which has a lot of branches to it, for example:

 

<?xml version="1.0" encoding="UTF-8"?>

<header xmlns="http://example.com" name="inbal">

<firstElement type="first">

   <secondElement>someText</secondElement>

        <thirdElement>

              <forthElement>sometext</forthElement>

              <forthElement>sometext2</forthElement>

        </thirdElement>

</firstElement>

</header>

 

does someone has a code that can help me read this XML?

I have tried to do it using the Xmlstreamreader but I am not sure that "reader.next" or "reader.hasnext" is actually going through the way on the children, does it enter to the children as well with no special method?

Thanks,

Inbal

_Prasu__Prasu_

You can try XMLDom class for XML parsing.

Link to projects: XML Dom parser

 

Also Fast XML is available:  Fast XML

inbaljS2inbaljS2

Thank you Prasanna. 

 

I have looked in both links, which one will you recommend more?

I found that on the XMLDom class there is no option to go to the next sibling inside the children....

 

Thank you, 

Inbal