Subject: RE: MS XML DOM question...
From: "Chris Bayes" <chris@xxxxxxxxxxx>
Date: Mon, 5 Nov 2001 22:45:15 -0000
|
Frank,
Mike is right. Off the top of my head.
I am presuming you have your xml in a domdocument called xml
XSLT version
xsl.loadXML('<?xml version="1.0"?><xsl:stylesheet
xmlns:x="http://www.w3.org/1999/XSL/Transform" version="1.0"><x:template
match="node()"><x:copy><x:apply-templates select="*"
/></x:copy></x:template><x:template match="BODY"><Section Title="title">
... </Section></x:template></x:stylesheet>');
xml.transformNodeToObject(xsl,xml);
DOM version
var sxml = xml.createNode(NODE_ELEMENT, "Section");
sxml.appendChild(xml.createTextNode(" ... "));
sxml.setAttribute("Title", "title");sxml =
xml.selectSingleNode("/HTML").appendChild(sxml);
xml.selectSingleNode("/HTML").removeChild(xml.selectSingleNode("/HTML/BO
DY");
Ok it looks a little longer but if you remove the xslt preamble i.e.
<?xml version="1.0"?><xsl:stylesheet
xmlns:x="http://www.w3.org/1999/XSL/Transform" version="1.0"> then it
isn't. And the logic is much easier to understand.
Ciao Chris
XML/XSL Portal
http://www.bayes.co.uk/xml
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Casadome, Francisco Javier
> Sent: 05 November 2001 21:24
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: RE: MS XML DOM question...
>
>
> I was expecting that answer :)
> Thanks anyway,
> Frank.
>
> -----Original Message-----
> From: Michael Kay [mailto:michael.h.kay@xxxxxxxxxxxx]
> Sent: lunes, 05 de noviembre de 2001 21:26
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: MS XML DOM question...
>
> > I don't know if this is the right place to ask this
> question but I'm
> > desperate :( I need to rename a node and add it an attribute using
> > DOM.
>
> This is the right place to ask the question if you want
> people to tell you that it would be easier to do it with XSLT.
>
> Mike Kay
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
Michael Kay - Mon, 5 Nov 2001 16:41:46 -0500 (EST)
Casadome, Francisco Javier - Mon, 5 Nov 2001 16:21:52 -0500 (EST)
- Chris Bayes - Mon, 5 Nov 2001 17:46:44 -0500 (EST) <=
|
|