I have a task where I'm transforming a response like this:

<Names>
    <Name>
      <First></First>
      <Last></Last>
      <Middle></Middle>
    </Name>
    <Name>
      <First></First>
      <Last></Last>
      <Middle></Middle>
    </Name>
</Names>

But I have to format it into nodes like this:

<name_first_1></name_first_1>
<name_last_1></name_last_1>
<name_middle_1></name_middle_1>
<name_first_2></name_first_2>
<name_last_2></name_last_2>
<name_middle_2></name_middle_2>

So I wanted to use position() to figure out a way to dynamically change the node name so I could do something like "<name_first_$value>". Am I coming from left field with this? :)


Any help would be greatly appreciated!

Thanks,

with which programme / language would like to access you the Xml file.
your beginning is wrong for your idea there is xpath with
<xsl:value-of select="Name[1]/First"/> the first name
<xsl:value-of select="Name[2]/First"/> the second name

so to predicates

Wow, the simplest solution evaded me. Thanks for your help!

Steve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.