Hi,
I like to parse an xml file to delete a node without deleting the child nodes by using a script. So I have the following XML structure:
node a
--- node b
------node c
Now I like to delete node a by parsing the xml file for the "<node a>" tag. The difficulty for me is to
- find a variable which could pickup the xml file and
- to find a variable to store the xml file content as a string
so that I can parse the xml content.
Kind regards
TomT
Parsing XML like txt
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Re: Parsing XML like txt
Use this style sheet
to convert from
to
Code: Select all
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<xsl:apply-templates select="node()" />
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<a>
<b>
<c/>
</b>
</a>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<b>
<c/>
</b>