Note that there are some explanatory texts on larger screens.

plurals
  1. POXPath 1.0: Returning a string from multiple node results?
    text
    copied!<p>So say I have a node structure like: </p> <pre><code>&lt;Row&gt; &lt;Column Name="Primary Number"&gt;1&lt;/Column&gt; &lt;Column Name="Secondary Number"&gt;01&lt;/Column&gt; &lt;Column Name="Text"&gt;This is all one sentence&lt;/Column&gt; &lt;Row&gt; &lt;Column Name="Primary Number"&gt;1&lt;/Column&gt; &lt;Column Name="Secondary Number"&gt;02&lt;/Column&gt; &lt;Column Name="Text"&gt;I would like to return&lt;/Column&gt; &lt;Row&gt; &lt;Column Name="Primary Number"&gt;1&lt;/Column&gt; &lt;Column Name="Secondary Number"&gt;03&lt;/Column&gt; &lt;Column Name="Text"&gt;as one string, in one xpath line&lt;/Column&gt; </code></pre> <p>First of all I would like to say this is not my xml, nor did I help construct it. But I am forced to use it to retrieve the info I need....So please help.</p> <p>So what I would like to do using one XPath, is to return one string containing the text from all n number of Text fields of all Primary Number=1 nodes.<br> Is this possible using XPath 1.0? </p> <p>I have a not-so elegant solution, but it only works if I know the exact number of secondary numbers, and then it's just a bunch of messy concat()'s...</p> <p><strong>Hello all, and thanks for everyone's response! So what I wanted to do with this string, was use contains() to search for specific keywords, but I found a shortcut around actually having a concatenated string of all the values to do so, and just had to share it in case someone had a similar problem. Tod's hint helped quite a bit with this, I just added a conditional to it and BAM magic. Here it is:</strong></p> <pre><code>Table[@Name='TableName']/Row/Column[@Name='Text' and contains(text(),"keyword")][preceding-sibling::Column[@Name='Primary Number' and text()='15']] </code></pre> <p><strong>So what this does is instead of concatenating all of the node value results as one string then using contains() on it, it searches each line for the word separately and thus removes the need for the impossible. Thanks for all the help guys, couldn't have done it without all the great responses!</strong> (I'd give everyone vote ups, but I'm too new :( )</p>
 

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