Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: IXMLDOMDocumentPtr MSXML2::IXMLDOMNodePtr question ???

From: pedro@------------.---
To: NULL
Date: 4/9/2008 8:47:00 AM
On 9 Abr, 09:21, pe...@code4cerveja.com wrote:
> On 8 Abr, 18:40, Martin Honnen <mahotr...@yahoo.de> wrote:
>
>
>
>
>
> > pe...@code4cerveja.com wrote:
> > > i am trying to get the first element from XML and add it the xmlns
> > > namespace
>
> > > how can i do this using =A0MSXML2 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
> > =A0 =A0xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
> > =A0 =A0version=3D"1.0">
>
> > =A0 =A0<xsl:output method=3D"xml"/>
>
> > =A0 =A0<xsl:param name=3D"ns" select=3D"'http://example.com/ns1'"/>
>
> > =A0 =A0<xsl:template match=3D"*">
> > =A0 =A0 =A0<xsl:element name=3D"{local-name()}" namespace=3D"{$ns}">
> > =A0 =A0 =A0 =A0<xsl:apply-templates select=3D"@* | node()"/>
> > =A0 =A0 =A0</xsl:element>
> > =A0 =A0</xsl:template>
>
> > =A0 =A0<xsl:template match=3D"@* | text() | comment() | processing-instr=
uction()">
> > =A0 =A0 =A0<xsl:copy/>
> > =A0 =A0</xsl:template>
>
> > </xsl:stylesheet>
>
> > --
>
> > =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> > =A0 =A0 =A0 =A0http://JavaScript.FAQTs.com/
>
> we did it like this but this way its not the most efficient, can you
> make this better
>
> thanks
>
> MSXML2::IXMLDOMNodePtr nodePtr;
>
> nodePtr=3DpDOMDoc->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),getT=
ipo().c_str(),GetTi=ADpoNS(getTipo()));
>
> pDOMDoc->loadXML(bstrXMLString);
>
> for(MSXML2::IXMLDOMNodePtr node=3DpDOMDoc->documentElement->firstChild;nod=
e!=3D0;node=3Dnode->nextSibling) {
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nodePtr->appendChild(node-=
>cloneNode(_variant_t((bool)true)));
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> pDOMDoc->loadXML(nodePtr->xml);- Ocultar texto citado -
>
> - Mostrar texto citado -

with strings is easier

string xmlteste=3Dteste;
string::size_type loc =3D xmlteste.find(">",0);
string tipo;
tipo.append(" ");
tipo.append("xmlns=3D");
tipo.append("'");
tipo.append(GetTipoNS(getTipo()));
tipo.append("'");
xmlteste.insert(loc,tipo);


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent