Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: A different XML structure, how to parse it?

  1. #1
    Join Date
    May 2013
    Posts
    19

    Default A different XML structure, how to parse it?

    The example structure here: http://forecast.weather.gov/MapClick...pe=digitalDWML
    <time-layout time-coordinate="local" summarization="none">
    <layout-key>k-p1h-n1-0</layout-key>
    <start-valid-time>2013-05-22T17:00:00-04:00</start-valid-time>
    <end-valid-time>2013-05-22T18:00:00-04:00</end-valid-time>
    <start-valid-time>2013-05-22T18:00:00-04:00</start-valid-time>
    <end-valid-time>2013-05-22T19:00:00-04:00</end-valid-time>
    <start-valid-time>2013-05-22T19:00:00-04:00</start-valid-time>
    <end-valid-time>2013-05-22T20:00:00-04:00</end-valid-time>
    <start-valid-time>2013-05-22T20:00:00-04:00</start-valid-time>
    <end-valid-time>2013-05-22T21:00:00-04:00</end-valid-time>
    <start-valid-time>2013-05-22T21:00:00-04:00</start-valid-time>
    <end-valid-time>2013-05-22T22:00:00-04:00</end-valid-time>




    <temperature type="hourly" time-layout="k-p1h-n1-0">
    <value>72</value>
    <value>70</value>
    <value>68</value>
    <value>65</value>
    <value>65</value>



    In this xml, all temperatures are put together in the same node, all time are put together in the same node, so how do I parse and map each temperature to the correct time? right now I'm just process each node and add a sequence, but is there any other way? or some xpath can do this?

    Thank you

  2. #2
    Join Date
    May 2013
    Posts
    12

    Default

    lol thats a bit complicated to undertand i am rather confused with this situation and the mentioned code words here
    .

  3. #3
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    You sure want to process the XML document only once.
    Attached Files Attached Files
    So long, and thanks for all the fish.

  4. #4
    Join Date
    May 2013
    Posts
    19

    Default

    Oh sorry about the confusion :-p
    Basically the problem is information are spread in different nodes. I need to map them...

    @Marabu
    Thank you so much! I just found my xpath skill is soooo poor, gotta do some extra lesson :-)
    Your solution is good, but in the actual xml file there will be more attributes to deal with, so when it scale up, the xpath expression could be huge and hard to control. However, your solution inspired me, I'm gonna do more research on it. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.