Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would likely use an XSLT stylesheet to solve this problem. I built the following stylesheet to be a little bit generic that exactly what you asked for, but it could easily be modified to give you the exact output you had specified if you truly need that exact output.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="/*"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/*"&gt; &lt;xsl:copy&gt; &lt;xsl:copy-of select="*"/&gt; &lt;xsl:element name="nodes"&gt; &lt;xsl:apply-templates select="*[normalize-space(.) = 'true']"/&gt; &lt;/xsl:element&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/*/*"&gt; &lt;xsl:value-of select="concat(',', local-name())"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/*/*[1]"&gt; &lt;xsl:value-of select="local-name()"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>This XSLT's output would be:</p> <pre><code>&lt;page&gt; &lt;audience1&gt; true &lt;/audience1&gt; &lt;audience2&gt; false &lt;/audience2&gt; &lt;audience3&gt; true &lt;/audience3&gt; &lt;audience4&gt; false &lt;/audience4&gt; &lt;audience5&gt; true &lt;/audience5&gt; &lt;nodes&gt;audience1,audience3,audience5&lt;/nodes&gt; &lt;/page&gt; </code></pre> <p>XSLT would be a good fit for this because you can use from almost any programming language you want or you could use Visual Studio to apply the template. There are also many <a href="http://saxon.sourceforge.net/" rel="nofollow noreferrer">free tools</a> out there that you could use to apply the transformations.</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