Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - IXMLDOMDocumentPtr MSXML2::IXMLDOMNodePtr question ??? >Thread Next - Re: IXMLDOMDocumentPtr MSXML2::IXMLDOMNodePtr question ??? Re: IXMLDOMDocumentPtr MSXML2::IXMLDOMNodePtr question ???To: NULL Date: 4/8/2008 7:40:00 PM pedro@c... wrote: > i am trying to get the first element from XML and add it the xmlns > namespace > > > > how can i do this using MSXML2 in C++ native ? The first element is the documentElement, there is a property for that that you can access <URL:http://msdn2.microsoft.com/en-us/library/ms759095(VS.85).aspx> However you can't change the namespace of nodes in a DOM document. If you want to change the namespace you need to create new nodes in the intended namespace. An XSLT stylesheet can do that easily and elegantly e.g. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:param name="ns" select="'http://example.com/ns1'"/> <xsl:template match="*"> <xsl:element name="{local-name()}" namespace="{$ns}"> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> <xsl:template match="@* | text() | comment() | processing-instruction()"> <xsl:copy/> </xsl:template> </xsl:stylesheet> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
