Note that there are some explanatory texts on larger screens.

plurals
  1. POReal Studio: finding position of XQL results in original XmlDocument
    primarykey
    data
    text
    <p>I have the following XML (stored in an XmlDocument):</p> <pre><code>&lt;root&gt; &lt;row&gt; &lt;elem&gt;Timestamp&lt;/elem&gt; &lt;elem&gt;ERB.CHW.BTU_CV&lt;/elem&gt; &lt;elem&gt;ERB.CHW.BTU1_CV&lt;/elem&gt; &lt;elem&gt;ERB.HW.BTU_CV&lt;/elem&gt; &lt;elem&gt;ERB.HW.BTU1_CV&lt;/elem&gt; &lt;elem&gt;ERB.KW.DEMAND_CV&lt;/elem&gt; &lt;elem&gt;ERB.KWH.MT_CV&lt;/elem&gt; &lt;elem&gt;&lt;/elem&gt; &lt;/row&gt; &lt;row&gt; &lt;elem&gt;2011/09/30 11:21:13.9062&lt;/elem&gt; &lt;elem&gt;2.307609E+09&lt;/elem&gt; &lt;elem&gt;1880067&lt;/elem&gt; &lt;elem&gt;1.068635E+08&lt;/elem&gt; &lt;elem&gt;1340.386&lt;/elem&gt; &lt;elem&gt;448.8&lt;/elem&gt; &lt;elem&gt;1427723&lt;/elem&gt; &lt;elem&gt;&lt;/elem&gt; &lt;/row&gt; &lt;/root&gt; </code></pre> <p>I am working with this query:</p> <pre><code>Dim results As XmlNodeSet = myDoc.xql("/*/row[1]/elem[normalize-space()]") </code></pre> <p>...which returns the XmlNodeSet back to me that I would expect:</p> <pre><code>&lt;elem&gt;Timestamp&lt;/elem&gt; &lt;elem&gt;ERB.CHW.BTU_CV&lt;/elem&gt; &lt;elem&gt;ERB.CHW.BTU1_CV&lt;/elem&gt; &lt;elem&gt;ERB.HW.BTU_CV&lt;/elem&gt; &lt;elem&gt;ERB.HW.BTU1_CV&lt;/elem&gt; &lt;elem&gt;ERB.KW.DEMAND_CV&lt;/elem&gt; &lt;elem&gt;ERB.KWH.MT_CV&lt;/elem&gt; </code></pre> <p>However, I would like to know <em>where</em> 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).</p> <p>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:</p> <ol> <li>Run an XSLT against the source document -- using my original XPath -- that puts extraneous markup in the original source document (e.g., <code>&lt;elem highlight="true"&gt;ERB.KWH.MT_CV&lt;/elem&gt;</code>). </li> <li>Use regular expressions within RS to figure out the positioning of the elements that contain this markup.</li> <li>Output a version of the document that (a) has the markup removed and (b) highlights the text in those positions.</li> </ol> <p>Yuck. Can anyone think of a better way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload