0
votes

I want generate list with column: Computer, Product Name, License Key from xml file:

<RecoverKeys>
  <Key>
    <Data name="Computer" value="john"/>
    <Data name="Product Name" value="Microsoft Office Professional Hybrid 2007"/>
    <Data name="License Key" value="xxxx-xxxx-xxxx-xxxx-xxxx"/>
    <Data name="Product ID" value="123123-345435-3451345-3453453"/>
    <Data name="User" value="N/A"/>
    <Data name="Company" value="N/A"/>
    <Data name="Auth. Key" value="N/A"/>
  </Key>
  <Key>
    <Data name="Computer" value="john"/>
    <Data name="Product Name" value="Roxio My DVD 9.0"/>
    <Data name="License Key" value="34756674"/>
    <Data name="Product ID" value="N/A"/>
    <Data name="User" value="N/A"/>
    <Data name="Company" value="N/A"/>
    <Data name="Auth. Key" value="N/A"/>
  </Key>
    <Key>
    <Data name="Computer" value="adam"/>
    <Data name="Product Name" value="Roxio My DVD 10.0"/>
    <Data name="License Key" value="456456456"/>
    <Data name="Product ID" value="N/A"/>
    <Data name="User" value="N/A"/>
    <Data name="Company" value="N/A"/>
    <Data name="Auth. Key" value="N/A"/>
  </Key>
    <Key>
    <Data name="Computer" value="tom"/>
    <Data name="Product Name" value="photoshop"/>
    <Data name="License Key" value="2342342423423"/>
    <Data name="Product ID" value="N/A"/>
    <Data name="User" value="N/A"/>
    <Data name="Company" value="N/A"/>
    <Data name="Auth. Key" value="N/A"/>
  </Key>
  </RecoverKeys>

I'm used XPath in Keetle Spoon for first column: //Data[@name='Computer']/@value but I get result:

john john john john

but I want:

john john adam tom

1
That XPath is correct. The issue might be elsewhere. I don't know anything about Kettle Spoon, but could you show us some of the code or whatever it is you are using to execute this XPath selection? - JLRishe
I'm using additional required setting: Loop XPath: "/RecoverKeys/Key/Data", when change it to: "/RecoverKeys/Key" the same output, when change it to "/RecoverKey" I get output only: john - Dario
That probably explains it. How about if you use the Loop XPath /RecoverKeys/Key, and then the (non-looping) XPath Data[@name = 'Computer']/@value? - JLRishe
It works!!! thanks , changed Xpath from //Data[@name='Computer']/@value to Data[@name='Computer']/@value - Dario
Dario, Why do you expect to get a correct answer, if you haven't shown to us the real XML document? Making people guess is unwise and typically doesn't result in good answers. Please, edit the question and provide a complete/real XML document. - Dimitre Novatchev

1 Answers

0
votes

From your comments, it sounds like what you are doing involves looping through nodes with one XPath and then applying another XPath from that context, so you need to use the loop XPath:

/RecoverKeys/Key

and the non-loop XPath:

Data[@name = 'Computer']/@value