Hi
I have a XML that is getting generated on click of a button in the form.
I am using xfa.data.saveXML("pretty"); to generate the XML.
Following is the XML,
<?xml version="1.0" encoding="UTF-8"?>
<xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<ELEMENT>
<DATA>
<ROW_IID>0</ROW_IID>
<PARENT>0</PARENT>
<CHILD>0</CHILD>
</DATA>
<NAME>
<FNAME>0</FNAME>
<LNAME>0</LNAME>
</NAME>
</ELEMENT>
</xfa:data>
I want to delete the <NAME> node in the XML and assign the manipulated XML to some text field.
Could anyone please let me know how to do the same?
Thanks:)
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Considering you want the output as a string you could use XSLT, so something like (which copies all xml nodes except the NAME one);
var stylesheet =
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "xml" omit-xml-declaration = "yes" indent = "yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="NAME"/>
</xsl:stylesheet>
var txt = $data.ELEMENT.applyXSL(stylesheet.toXMLString());
console.println(txt)
You could also use;
$data.ELEMENT.nodes.remove($data.ELEMENT.NAME)
console.println($data.ELEMENT.saveXML("pretty"));
Regards
Bruce
Views
Replies
Total Likes
Hi,
Considering you want the output as a string you could use XSLT, so something like (which copies all xml nodes except the NAME one);
var stylesheet =
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "xml" omit-xml-declaration = "yes" indent = "yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="NAME"/>
</xsl:stylesheet>
var txt = $data.ELEMENT.applyXSL(stylesheet.toXMLString());
console.println(txt)
You could also use;
$data.ELEMENT.nodes.remove($data.ELEMENT.NAME)
console.println($data.ELEMENT.saveXML("pretty"));
Regards
Bruce
Views
Replies
Total Likes
Hi Bruce,
Its working!!..Thanks you so much:-)
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies