BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
XML DOM
The DOM Method: setNamedItem()
The DOM Method: setAttributeNode()
The DOM Method: setAttribute()
The DOM Method: send()
The DOM Method: selectSingleNode()
The DOM Method: selectNodes()
The DOM Method: save()
The DOM Method: reset()
The DOM Method: replaceChild()
The DOM Method: removeNamedItem()
The DOM Method: removeChild()
The DOM Method: removeAttributeNode()
The DOM Method: removeAttribute()
The DOM Method: nodeFromID()
The DOM Method: nextNode()
The DOM Method: loadXML()
The DOM Method: load()
The DOM Method: insertBefore()
The DOM Method: hasChildNodes()
The DOM Method: getNamedItem()
<< XHTML
XmlSerializer >>

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :1714

 

transformNode()

Is a member of:
DOMDocument
XMLDOMNode
XMLDOMAttribute
XMLDOMCDATASection
XMLDOMComment
XMLDOMDocumentFragment
XMLDOMDocumentType
XMLDOMElement
XMLDOMEntity
XMLDOMEntityReference
XMLDOMNotation
XMLDOMProcessingInstruction
XMLDOMText
XTLRuntime

Syntax

strVAlue = objDOMDocument.transformNode(strStylesheet)

Remark

The transformNode() method applies a stylesheet to the current Node and its child Nodes. It returns this data in a string, which is very useful for when you want to pass your data back as HTML (which means that your XSL file needs to convert your XML data to HTML):

strValue = objDOMDocument.transformNode(strStylesheet)

The string strValue will contain the contents to transform the Node into the required string. For more information, see chapter 5, "XSL-adding style to XML."

Example

The following example shows the string from the transformed Node being passed back using the transformNode() method. We use people2.xml to demonstrate the transformNode() method.

Our XSL example looks as follows:

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">

<HTML>

<BODY>

<TABLE BORDER="2">

<TR>

<TD>Name</TD>

<TD>Address</TD>

<TD>Tel</TD>

<TD>Fax</TD>

<TD>Email</TD>

</TR>

<xsl:for-each select="PEOPLE/PERSON">

<TR>

<TD><xsl:value-of select="NAME"/></TD>

<TD><xsl:value-of select="ADDRESS"/></TD>

<TD><xsl:value-of select="TEL"/></TD>

<TD><xsl:value-of select="FAX"/></TD>

<TD><xsl:value-of select="EMAIL"/></TD>

</TR>

</xsl:for-each>

</TABLE>

</BODY>

</HTML>

</xsl:template>

</xsl:stylesheet>

The code is:

Dim objXMLStyle As New DOMDocument

Dim objDOMDocument As New DOMDocument

Dim strXMLFromXSL As String

Call objDOMDocument.Load("http://localhost/xmlcode/people2.xml")

Call objXMLStyle.Load("http://localhost/xmlcode/people.xsl")

strXMLFromXSL = objDOMDocument.transformNode(objXML-Style.documentElement)

The strXMLFromXSL string returns the following HTML:

<HTML>

<BODY>

<TABLE BORDER="2">

<TR>

<TD>Name</TD>

<TD>Address</TD>

<TD>Tel</TD>

<TD>Fax</TD>

<TD>Email</TD>

</TR>

<TR>

<TD>Mark Wilson</TD>

<TD>911 Somewhere Circle, Canberra, Australia</TD>

<TD>(++612) 12345</TD>

<TD>(++612) 12345</TD>

<TD>markwilson@somewhere.com</TD>

</TR>

<TR>

<TD>Tracey Wilson</TD>

<TD>121 Zootle Road, Cape Town, South Africa</TD>

<TD>(++2721) 531 9090</TD>

<TD>(++2721) 531 9090</TD>

<TD>Tracey Wilson@somewhere.com</TD>

</TR>

<TR>

<TD>Jodie Foster</TD>

<TD>30 Animal Road, New York, USA</TD>

<TD>(++1) 3000 12345</TD>

<TD>(++1) 3000 12345</TD>

<TD>Jodie Foster@somewhere.com</TD>

</TR>

<TR>

<TD>Lorrin Maughan</TD>

<TD>1143 Winners Lane, London, United Kingdom</TD>

<TD>(++94) 17 12345</TD>

<TD>++94) 17 12345</TD>

<TD>Lorrin Maughan@somewhere.com</TD>

</TR>

<TR>

<TD>Steve Rachel</TD>

<TD>90210 Beverly Hills, California, United States of America</TD>

<TD>(++1) 2000 12345</TD>

<TD>(++1) 2000 12345</TD>

<TD>Steve Rachel@somewhere.com</TD>

</TR>

</TABLE>

</BODY>

</HTML>


This manuscript is an abridged version of a chapter from the Manning Publications book XML Programming with VB and ASP. This chapter looks at the Microsoft DOM objects. NOTE: Most images have been removed to increase speed and many of the code comments have also been removed for presentation. Please purchase the book to enjoy the full experience of all the chapters with images and code comments!


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)




swimming pool contractor
chicago web site design
fax online
Domain Names
online fax
D&g sunglasses
answering service


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP