🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Read XML data with multiple child nodes and transform into examples

User: "etmpoon999"
New Altair Community Member
Updated by Jocelyn
I have records in XML like the one below. Each record has one parent <Id></id> and unlimited number of child events. Each event has it's own <EventId></EventId>. All <Id> and <EventId> are unique.

<list>
  <Request>
    <hd_att1>false</hd_att1>
    <hd_att2>true</hd_att2>
    <detail>
      <info1>false</info1>
      <info2>false</info2>
      <Id>14901</Id>
      <Events>
        <Event>
          <name>false</name>
          <EventId>14253</EventId>
          <eventloc>
            <Name>abc</Name>
          </eventloc>
          <target>
            <Name>xyz</Name>
          </target>
        </Event>
        <Event>
          <name>false</name>
          <EventId>25873</EventId>
          <eventloc>
            <Name>abc</Name>
          </eventloc>
          <target>
            <Name>xyz</Name>
          </target>
        </Event>
      </Events>
    </detail>
  </Request>
</list>

I am managed to use Generate Extract to read the XML data by manually adding 20 child XPathes. The resulting example is one row with a parent and 20 children like the one below.

<Id>, <hd_att1>, <hd_att2>, <info1>, <info2>, <event.name1>, <event.EventId1>, <event.eventloc.name1>, <event.target.name1>, <event.name2>, <event.EventId2>, <event.eventloc.name2>, <event.target.name2>, .....

I actually need examples of parents with each of its own child like the below.

<Id>, <hd_att1>, <hd_att2>, <info1>, <info2>, <event.name>, <event.EventId>, <event.eventloc.name>, <event.target.name>
<Id>, <hd_att1>, <hd_att2>, <info1>, <info2>, <event.name>, <event.EventId>, <event.eventloc.name>, <event.target.name>

I can't find how to transform the row into multiple rows by attributes. Please help.

And, may be you have better idea to extract the child nodes instead of manually adding child XPathes.




























Find more posts tagged with

No comments on this post.