XML XPath read individual lines

Hello All;

I am working with large XML file and would like to read one line at a time, but I am having trouble getting xPath to read the specified line.

Right now, I am getting all values on all lines then using getSlice to pull out the data that is needed. This is very heavy and inefficient.

I am having trouble reading the x, y, z values from one value line at a time.
Here is an example chunk of XML I would like to read:

<Data name="pPointRx" access="private" xsi:type="array" type="pointRx" size="11">
  <Value key="0" x="266.531827365" y="-112.628010652" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="1" x="266.531827365" y="-86.70961806" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="2" x="266.531827365" y="-60.7912254682" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="3" x="266.531827365" y="-34.8728328765" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="4" x="266.531827365" y="-8.95444028481" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="5" x="266.531827365" y="16.9639523069" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="6" x="266.531827365" y="42.8823448986" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="7" x="266.531827365" y="68.8007374903" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="8" x="266.531827365" y="94.719130082" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="9" x="266.531827365" y="120.637522674" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />
  <Value key="10" x="266.531827365" y="146.555915265" z="75.3852662391" ry="90" rz="90" fatherId="world[0]" />

I can get all “x” values using this xPath Query:
/Database/Datas/Data[@name=“pPointRx”]/Value/@x

Is there a way I could get the x,y,z from a single value line (maybe using the key data?)?

Thank you for the help!
Kind regards,
Jake

Link the XML file (I’d remove everything useless, and I’d add just the XML namespace and a superparent tag) to an AsXElement (XML) node, then downstream place a GetElements and further down a GetAttribute; finally an Attribute node.
GetElements will need the text “Value” to find all the Value tags, GetAttributes would be fed with a spread by a Select (String Bin) node, which would be fed like this: Input = the attributes you want to retrieve in the order you want to retrieve them, BinSize = the number of the attributes to be retrieved (in order to have all of the x,y,z triplets of each line), Select = the content of GetElements’ Elements Bin Size pin (so a link between the two nodes would suffice).

You should then patch your logic to gather and process retrieved data.

If using GetSlice feels very heavy and inefficient, chances are that either your file is huge so it’s a machine issue or the patched logic needs some tuning. IMMHO.

Many ways…
Rome.zip (4.1 KB)

Definitely.

Hey bjoern,

Thank you for the example! I will try it out and see if it solves the performance issue.
The far right solution seems to be what I was trying to figure out how to do.

h99, thank you for the description of how to solve the issue. I will try out bjoern’s setups and report back.

Thank you for the help!

Edit:

I was able to get bjoern’s example to work with much better performance than I had previously.
I changed the XPath Query a bit so it samples the correct data from different point names each with the x,y,z values.

/Database/Datas/Data[@name=‘pPointRx’]/Value[@key=’#’]/@x | /Database/Datas/Data[@name=‘pPointRx’]/Value[@key=’#’]/@y | /Database/Datas/Data[@name=‘pPointRx’]/Value[@key=’#’]/@z

Kind regards,
Jake

One last question, if I may.

How could I see how many points there are in the list?
Now that I am only pulling one point at a time, I don’t know what key is my last point.

Thanks for the help!

If per point you mean a single “Value” tag, GetElements could help. See bjoern’s example to find how it works.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.