BizTalk Utilities CV ,   Jobs ,   Code library  
 
 

Microsoft DOM Objects Reference

Download ReferenceDownload this Reference 

Previous PageTable Of ContentsIndexNext Page

selectSingleNode()

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

Syntax

Set objXMLDOMNode = objXMLDOMElement.selectSingleNode(strXQLQuery)

Remark

Once again, as in the selectNodes() method, selectSingleNode() uses XQL to find the required Node. However, it only returns a single Node, XMLDOMNode object, which is the first Node that matches the pattern if it's found. If no match is found, it returns NULL.

Example

The selectNodes() and selectSingle-Node() methods can also be used to search for Nodes that have certain attribute values. As we mentioned, you will need to do a bit of research to work out how to work with XQL, which we do not cover in detail here.

In the following example, we iterate through all the childNodes in the documentElement collection. We only want to find the NAME element in each PERSON element.

Dim objDOMDocument As DOMDocument

Dim objXMLDOMNode As IXMLDOMNode

Dim objElement As IXMLDOMElement

Set objDOMDocument = New DOMDocument

objDOMDocument.async = False

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

For Each objXMLDOMNode In objDOMDocument.documentElement.childNodes

Set objElement = objXMLDOMNode.selectSingleNode("NAME")

' do something with this name element

Next

Look at getElementsByTagName(), which does almost the same thing as this method. The beauty of this method, however, is that it returns a single Node instead of an XMLDOMNodeList. Therefore, this method is easier to work with, as you don't need to iterate through a NodeList collection to just get the one value out of it.

Previous PageTable Of ContentsIndexNext Page

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!

 

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)



Information Online

swimming pool builder
chicago web site design
spfxmasks
Cheap Web Hosting
conference calling
Prada 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