Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>XPath is a query language for XML documents and as such it cannot alter the structure of a document</strong>.</p> <p><strong>XSLT is a proper tool for transforming an XML document into another</strong>. The XSLT solution of this problem is:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/*"&gt;&lt;xsl:apply-templates/&gt;&lt;/xsl:template&gt; &lt;xsl:template match="One/node()|Two/node()"/&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied on the provided XML document:</strong></p> <pre><code>&lt;Programme&gt; &lt;Intakes&gt; &lt;One&gt; &lt;Information /&gt; &lt;/One&gt; &lt;Two&gt; &lt;Information /&gt; &lt;/Two&gt; &lt;/Intakes&gt; &lt;/Programme&gt; </code></pre> <p><strong>the wanted, correct result is produced:</strong></p> <pre><code>&lt;Intakes&gt; &lt;One/&gt; &lt;Two/&gt; &lt;/Intakes&gt; </code></pre> <p><strong>UPDATE</strong>: The OP has changed the question radically -- now the wanted result is:</p> <pre><code>One Two </code></pre> <p>This still cannot be provided by a single XPath 1.0 expression (and as you are using C#, you probably don't have access to an XPath 2.0 implementation).</p> <p><strong>You have first to select all children elements of <code>Intakes</code>:</strong></p> <pre><code>/*/Intakes/* </code></pre> <p><strong>Then you have to iterate through the returned node-set and for each element contained in it evaluate this XPath expression</strong>:</p> <pre><code>name() </code></pre>
 

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