Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>So, what XPath function will allow me to replace the 255, for another string? Or do I need something other than XPath for this?</p> </blockquote> <p><strong>XPath is the query language for XML and as such cannot modify an XML document</strong>.</p> <p>In order to modify an XML document one needs to use the programming language (such as XSLT, C#, JS, PHP, ..., etc) that is hosting XPath.</p> <p><strong>Here is a solution, where the hosting language is XSLT</strong>:</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:param name="pNewLineColor" select="123"/&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="@F_LINE_COLOR"&gt; &lt;xsl:attribute name="{name()}"&gt; &lt;xsl:value-of select="$pNewLineColor"/&gt; &lt;/xsl:attribute&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when this transformation is applied on the provided XML document</strong>:</p> <pre><code>&lt;MineX STATE="add"&gt; &lt;Desc F_CREATOR="admin" F_ENTRYDATE="2010-12-24" F_HEIGHT="0.875" F_ID="1" F_LEFT="1.15625" F_LINE_COLOR="255" F_FORECOLOR="0"&gt; &lt;F_CUSTOM_BYTES&gt;&lt;/F_CUSTOM_BYTES&gt; &lt;/Desc&gt; &lt;/MineX&gt; </code></pre> <p><strong>the wanted, correct result is produced</strong>:</p> <pre><code>&lt;MineX STATE="add"&gt; &lt;Desc F_CREATOR="admin" F_ENTRYDATE="2010-12-24" F_HEIGHT="0.875" F_ID="1" F_LEFT="1.15625" F_LINE_COLOR="123" F_FORECOLOR="0"&gt; &lt;F_CUSTOM_BYTES&gt;&lt;/F_CUSTOM_BYTES&gt; &lt;/Desc&gt; &lt;/MineX&gt; </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