I have the following code with a small snippet of XML. How can I use XSLT to extract a single node from the XML:
Option Explicit Const strXSLT As String = "<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">" _& "<xsl:output indent=""yes""/><xsl:template match=""*""><xsl:copy>" _& "<xsl:copy-of select=""/Root/Item1""/>" _& "</xsl:copy></xsl:template></xsl:stylesheet>" Const strXML As String = "<Root><Item1>A</Item1><Item2>B</Item2></Root>" Sub Test() Dim oXMLDoc As Object Dim oXSLT As Object Dim strXML As String Set oXMLDoc = CreateObject("MSXML2.DOMDocument") Set oXSLT = CreateObject("MSXML2.DOMDocument") oXMLDoc.LoadXML strXML oXSLT.LoadXML strXSLT strXML = oXMLDoc.transformNode(oXSLT) Debug.Print strXML End Sub
My desired output would be:
<Item1>A</Item1>
Thanks.
Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm