Can I pull data from XML with identically named children under one parent ?

edited November 2014 in How To...

Hi folks -- I think I know the answer to this, but I want to double-check: is there a way to create a for loop that can extract all of the integers in "data/parameters/cloud-amount/value"? Thanks.

For example:

<parameters applicable-location="point1">
<cloud-amount type="total" units="percent" time-layout="k-p3h-n40-1">
<name>Cloud Cover Amount</name>
<value>60</value>
<value>53</value>
...
<value>46</value>
<value>34</value>
</cloud-amount>
</parameters>

Live: NOAA Weather Center National Digital Forecast Database (Sample Result)

Tagged:

Answers

  • Answer ✓

    Moved as I don't see Processing code in your question.

    I think getChildren(), returning an array of XML elements, is what you look for.

  • Oops, good point, thanks for moving this, PhiLho...

    Hmm -- for some reason I thought getChildren wasn’t working; instead I decided to just crawl the tree until I found the data and then start a new array from that item’s line number.

    But thanks to you I’m revisiting getChildren and it looks like I’m using it correctly now! Cheers.

Sign In or Register to comment.