   
nodeName
Is a member of:
|
DOMDocument
XMLDOMNode
XMLDOMAttribute
XMLDOMCDATASection
XMLDOMComment
XMLDOMDocumentFragment
XMLDOMDocumentType
XMLDOMElement
XMLDOMEntity
XMLDOMEntityReference
XMLDOMNotation
XMLDOMProcessingInstruction
XMLDOMText
XTLRuntime
|
SyntaxstrValue = objDOMDocument.nodeName
RemarkThis property is read-only. Depending on the type of
Node, this property returns a string containing the Node's name. This is
especially useful with elements and attributes. Table details what is
being represented by the nodeName property for the different interfaces of the
DOMDocument.
0.0.1 Return values for the different XMLDOM interfaces (continued)
Interface
name
|
Return value
|
XMLDOMElement
|
The name of the element tag is
returned, without the tag indi cators (</>).
XML Example:
<EMAIL>markwilson@somewhere.com</ EMAIL>
Returns: EMAIL
When dealing with namespaces , the full tag name
is returned.
XML Example:
<resume:EMAIL>markwilson@some
where.com</resume:EMAIL>
Returns:
resume:EMAIL
|
XMLDOMAttribute
|
The name of the element is
returned.
XML Example: <PERSON
PERSONID="p1">
Returns:
PERSONID
|
XMLDOMProcessingIn struction
|
The target of the processing
instruction is returned. This is the first word after the `<?'
indicators.
XML Example: <?xml version="1.0"
?>
Returns: xml
|
XMLDOMEntityReference
|
The name of the entity that is being
references is returned, stripping off the entity reference indicators,
namely the "&;".
XML Example: <ADDRESS>30 Animal Road, New York, &USA;</ADDRESS>
Returns: USA
|
XMLDOMEntity
|
The name of the entity is
returned.
XML Example: <!ENTITY USA "United
States of America">
Returns: USA
|
XMLDOMDocumentType
|
The name of the document type (DTD)
is returned.
XML Example: <!DOCTYPE PEOPLE
SYSTEM "http://localhost/xml code/people.dtd">
Returns:
PEOPLE
|
XMLDOMNotation
|
The name of the notation is
returned.
XML Example: <img
src="http://localhost/xmlcode/vbdev.gif">
Returns:
img
|
The Node types listed in table do not have
nodeNames; therefore, they return the following string literals of what is being
referenced.
0.0.1 Return values for XMLDOM interfaces with no nodeNames
Interface
name
|
Return value
|
XMLDOMText
|
#text
|
XMLDOMComment
|
#comment
|
XMLDOMCDATASection
|
#cdata-section
|
XMLDOMDocument
|
#document
|
XMLDOMDocumentFragment
|
#document-fragment
|
ExampleWhen we want to populate the textboxes on a VB form, we
use the nodeName property to work with a Select Case as the decider of which
text box should be populated.
In the following example, we have already obtained a
reference to an element, which in this case is the PERSON element from our main
XML example. We are now looping through its child Nodes, differentiating which
Node is current by its nodeName property.
For Each objChildElement In objPersonElement.childNodes
If objChildElement.nodeType = NODE_ELEMENT Then
Select Case UCase(objChildElement.nodeName)
Case "NAME"
txtName.Text = objChildElement.nodeTypedValue
Case "ADDRESS"
txtAddress.Text = objChildElement.nodeTypedValue
Case "TEL"
txtTel.Text = objChildElement.nodeTypedValue
Case "FAX"
txtFax.Text = objChildElement.nodeTypedValue
Case "EMAIL"
txtEmail.Text = objChildElement.nodeTypedValue
End Select
End If
Next objChildElement    
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!
|