Reputation: 3738
I have the following XML (stored in an XmlDocument):
<root>
<row>
<elem>Timestamp</elem>
<elem>ERB.CHW.BTU_CV</elem>
<elem>ERB.CHW.BTU1_CV</elem>
<elem>ERB.HW.BTU_CV</elem>
<elem>ERB.HW.BTU1_CV</elem>
<elem>ERB.KW.DEMAND_CV</elem>
<elem>ERB.KWH.MT_CV</elem>
<elem></elem>
</row>
<row>
<elem>2011/09/30 11:21:13.9062</elem>
<elem>2.307609E+09</elem>
<elem>1880067</elem>
<elem>1.068635E+08</elem>
<elem>1340.386</elem>
<elem>448.8</elem>
<elem>1427723</elem>
<elem></elem>
</row>
</root>
I am working with this query:
Dim results As XmlNodeSet = myDoc.xql("/*/row[1]/elem[normalize-space()]")
...which returns the XmlNodeSet back to me that I would expect:
<elem>Timestamp</elem>
<elem>ERB.CHW.BTU_CV</elem>
<elem>ERB.CHW.BTU1_CV</elem>
<elem>ERB.HW.BTU_CV</elem>
<elem>ERB.HW.BTU1_CV</elem>
<elem>ERB.KW.DEMAND_CV</elem>
<elem>ERB.KWH.MT_CV</elem>
However, I would like to know where in the source XML this XmlNodeSet occurs (so that I can use a highlighting function -- which takes a starting point and a length, both integers -- to highlight these results in the original document).
From what I can tell, there's no obvious way to compare my result NodeSet against the original XmlDocument (and somehow get the position of those elements within that source document). I've experimented with some ideas and thus far, the only one I can think of is the following horrible process:
<elem highlight="true">ERB.KWH.MT_CV</elem>
). Yuck. Can anyone think of a better way?
Upvotes: 0
Views: 238
Reputation: 24627
See the source code of XPath Visualizer -- you can download it at:
http://www.huttar.net/dimitre/XPV/TopXML-XPV.html
The relevant code is in the XSLT stylesheet.
References
Upvotes: 0