XML - how to select the whole XML-Node

Hey there,

Im looking at this example code:

In order to re-use the whole String of ‘NODE’ in a setPatch operation, I would need to get this returned by XPath. What is the proper syntax to get:

I know how to select and return attributes with for example this query:

/PATCH/NODE@nodename=‘Generators\test.v4p’/@*

But I haven’t found a way to select/return the whole Node for which

@nodename=‘Generators\test.v4p’

is true.

I found on
http://www.w3schools.com/xpath/xpath_syntax.asp
ways to navigate the selected nodes

But when I write something like

/PATCH/NODE@nodename=‘Generators\test.v4p’/…

I get an empty string (instead of nil, which means somehow it’s a valid query)

Anybody got a clue?

Thanks!

Eno


Update: I haven’t found a way to tell the wiki not to make @nodename='Generators\test.v4p a link. please igonre this, and complete it with the square brackets it’s taken away

use xslt instead:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:copy-of select="//NODE[@nodename='Generators\test.v4p'](@nodename='Generators\test.v4p')" />
</xsl:template>
</xsl:stylesheet>

and mind that you must use double quotes for the select statement and single quotes for the string of the nodename

Funky, that works perfect!
After posting this I continued to research and thought xslt might be the way to go, but I#m just to fresh at it.
Thanks Woei!

  • Eno