0

I want to populate an XML in HTML page and generate xpath when clicked on a xml node/html element. Assume I have below xml.

<bookstore>
  <book category="web">
   <title lang="en">XQuery Kick Start</title>
   <author>Kurt Cagle</author>
   <year>2003</year>
   <price>49.99</price>
  </book>
</bookstore>

Now I want populate this xml in HTML page and when user clicks on <bookstore> I want to return '/bookstore', click on <book> should return '/bookstore/book' and click on <title> should return '/bookstore/book/title'. I want to achieve this using javascript or jquery or angular2. I can achieve this by hard coding the above xml in HTML page but the actual xml is very huge so trying to find some other approach where I can dynamically populate and achieve this requirement.

user3878988
  • 761
  • 3
  • 8
  • 20
  • 1
    using XSLT may be a start - see http://stackoverflow.com/a/5722617/5053002 – Jaromanda X Jan 20 '17 at 02:41
  • AFAIK XML support was removed from Chrome. You'd need some 3rd-party XML library that can do the XML/XSLT parsing and processing for you. – Günter Zöchbauer Jan 20 '17 at 06:56
  • It is not about displaying only, the main thing is to get the Xpath when clicked on particular node. If we display as .xsl/xml it is displaying as a single string, so I cannot capture the user clicked on which node. Displaying can also be achieved by appending xml in
     tag, but here also it is displayed as single string.
    – user3878988 Jan 20 '17 at 14:56

0 Answers0