This site has been taken over by the staff of www.ASPDeveloper.Net

Please report errors to suggest@aspdeveloper.net

BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
XML DOM
The DOM Property: tagName
The DOM Property: resolveExternals
The DOM Property: preserveWhiteSpace
The DOM Property: prefix
The DOM Property: parseError
The DOM Property: parsed
The DOM Property: parentNode
The DOM Property: ownerDocument
The DOM Property: ondataavailable
The DOM Property: nodeValue
The DOM Property: nodeTypeString
The DOM Property: nodeTypedValue
The DOM Property: nodeType
The DOM Property: nodeName
The DOM Property: namespaceURI
The DOM Property: length
The DOM Property: documentElement
The DOM Property: docType
The DOM Property: data
The DOM Property: childNodes
<< 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 :2506

 

text

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

Syntax

strValue = objXMLDOMNode.text

Remark

For writing the values to a Node, the text property is used. The text property normalizes white space, unless the DOMDocument has been specified to preserve the white space (see the preserveWhiteSpace property).

When reading the value of a Node, using the text property can lead to some strange behavior if your current Node has children.

Example

The following XML example explains what we meant by the previous comment.

<PEOPLE>

<PERSON id="1">

<NAME>Mark Wilson</NAME>

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

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

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

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

</PERSON>

....

</PEOPLE>

For the other properties, like the nodeType property, we explained how to get references to CDATA sections, etc. However, if you are looking for the text of a Node and are not too concerned about interrogating whether the subchildren consist of CDATA sections or entities, then just getting the text property will return the parsed data of your element.

In our example we have loaded our DOMDocument, which consists of our People2.xml file. We then get a reference to the firstChild property (objNode = '<PERSON id="1">') of the documentElement property:

Dim objDOMDocument As DOMDocument

Dim objNode As IXMLDOMNode

Dim strText as String

Set objDOMDocument = New DOMDocument

objDOMDocument.async = False

objDOMDocument.resolveExternals = True

objDOMDocument.validateOnParse = True

objDOMDocument.Load "http://localhost/xmlcode/people2.xml"

Set objNode = objDOMDocument.documentElement.firstChild

strText = objNode.text

Our objNode has child Nodes; therefore, its text property returns the values of all its child Nodes. The string strText returns the following:

Mark Wilson 911 Somewhere Circle, Canberra, Australia (++612) 12345 (++612) 12345 markwilson@somewhere.com"

The value return has all the tags, and the less than (<) and greater than (>) signs have been removed, with a space inserted between each child for the current Node.


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

Software Specialist, Linux - Finlan
Linux Core Technical Project Manage
Graphics designer at Tanzania. Expe
Integration Specialist Needed - Wor
Virtualization Server Infrastructur

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






    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