Suppose, I have an XML with descriptions of files and directories (where XML nodes of files that belong to some directory are nested into that directory's corresponding XML node):
<list>
<signature>
hash...
</signature>
<file id="44">
<data>
<length>1759</length>
<offset>36491175</offset>
<size>1018</size>
<encoding style="application/x-gzip"/>
<extracted-checksum style="sha1">91e4e9a81d6b8abb07fd6009afe72178997c512b</extracted-checksum>
<archived-checksum style="sha1">f141cb115e21de3320c1afccd2dc115b78f83661</archived-checksum>
</data>
<type>file</type>
<name>dist.dat</name>
</file>
<file id="6">
<ctime>1970-01-01T00:00:00Z</ctime>
<mtime>1970-01-01T00:00:00Z</mtime>
<atime>1970-01-01T00:00:00Z</atime>
<group>wheel</group>
<gid>0</gid>
<user>root</user>
<uid>0</uid>
<mode>0700</mode>
<deviceno>0</deviceno>
<inode>0</inode>
<type>directory</type>
<name>src</name>
<file id="7">
<ctime>1970-01-01T00:00:00Z</ctime>
<mtime>1970-01-01T00:00:00Z</mtime>
<atime>1970-01-01T00:00:00Z</atime>
<group>wheel</group>
<gid>0</gid>
<user>root</user>
<uid>0</uid>
<mode>0700</mode>
<deviceno>0</deviceno>
<inode>0</inode>
<type>directory</type>
<name>Dede</name> // ! Notice no closing </file> tag yet because next file is inside this directory
<file id="8">
<data>
<length>514</length>
<offset>36357051</offset>
<size>859</size>
<encoding style="application/x-gzip"/>
<extracted-checksum style="sha1">b13b86984f1ceeb698e879ad4a0c4174804529c3</extracted-checksum>
<archived-checksum style="sha1">414b16e24dbbbbf864d68bcde726d52d69a4dc04</archived-checksum>
</data>
<type>file</type>
<name>Hello.txt</name>
</file>
<file id="9">
<data>
<length>776</length>
<offset>36357665</offset>
<size>1630</size>
<encoding style="application/x-gzip"/>
<extracted-checksum style="sha1">318eec584b12f2333133d8d07bf6b2d883fa7070</extracted-checksum>
<archived-checksum style="sha1">c1d196e28e7a8ec0444f7d16f205bd67667f5eec</archived-checksum>
</data>
<type>file</type>
<name>Local_st.txt</name>
</file>
</file> // ! Closing </file> tag for the 'Dede' directory
... More File Nodes
</list>
What would be the best way to collect the offsets (or any desired properties for that matter) from all file nodes that have <type>file</type> and disregard "file" nodes that have <type>directory</type>?
Is there a native way or a library to do it? Or, if I manage to convert this XML into a JASON first, how would I do it then? This has to work completely browser-side.
Thanks