Querying xml element which refers to another element through xpath reference

Hi ,

I have a big xml in which there are many elements, which has internal xpath reference to another element.

Here is xml -

<publishers>
  <app.test.module.library.Publisher>
    <typeId>
      <selectedId>101</selectedId>
      <selectedText>Book</selectedText>
    </typeId>
    <regionCode>
      <selectedId>102</selectedId>
      <selectedText>NWD</selectedText>
    </regionCode>
  </app.test.module.library.Publisher>
  <app.test.module.library.Publisher>
    <typeId reference="../../app.test.module.library.Publisher/typeId" />
    <regionCode>
      <selectedId>101</selectedId>
      <selectedText>UWY</selectedText>
    </regionCode>
  </app.test.module.library.Publisher>
  <app.test.module.library.Publisher>
    <typeId>
      <selectedId>100</selectedId>
      <selectedText>Deposit</selectedText>
    </typeId>
    <regionCode>
      <selectedId>100</selectedId>
      <selectedText>WHU</selectedText>
    </regionCode>
  </app.test.module.library.Publisher>
</publishers>

So the typeId of second Publisher element points to the typeId of First Publisher element [ <typeId reference="../../app.test.module.library.Publisher/typeId" /> ]

While querying in the sql, there has to be some way to reach to the referred element but I have not been able to figure out so far.

would appreciate some help here.

Thanks


  • Edited by jsh2015 Friday, March 27, 2015 12:27 AM corrected the question with providing more details
March 26th, 2015 7:43pm

You need to search for an attribute (not element).  Any property inside a tag with an equal sign is call an attribute.  See webpage below

http://stackoverflow.com/questions/25135788/linq-to-xml-query-get-element-attribute


Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 12:41am

Actually I need to go to that referenced element and as I have mentioned in the question, this needs to be achieved in a sql query not in java.
March 27th, 2015 1:43pm

What Java are you refereeing to?
Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 3:25pm

simply put, if you can tell me how can you get typeId/selectedText value for the second app.test.module.library.Publisher element through a sql query ?
March 27th, 2015 4:48pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics