Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - difference between IXMLDOMElement and IXMLDOMNode [Thread Next] Re: difference between IXMLDOMElement and IXMLDOMNodeTo: NULL Date: 10/1/2005 12:23:00 PM
alexl wrote:
> not clear on the difference between IXMLDOMElement and IXMLDOMNode. I
> thought they both represent a tag?
> <sampletag>
^^^^^^^^^^
That is a tag, a start tag, and here
</sampletag>
^^^^^^^^^^^
you have another tag, an end tag. In the markup (the source code of an
XML document) there are tags while on the logical structure there are
elements.
In the DOM a hierachical object oriented approach has been taken to
model an XML document as a tree of nodes where you have a common base
class or interface Node and other more specialized interfaces or classes
that extend Node, e.g. Element, Document, Text, Attribute,
ProcessingInstruction, Comment.
So everything you have in the DOM object model of an XML document is a
node and has at least the properties and methods defined for the Node
interface (or IXMLDOMNode in the case of MSXML).
But while there are common properties and methods all types of nodes
share there a specialized properties/methods for for instance element
nodes and these are defined by the Element respectively IXMLDOMElement
interface.
As long as you use dynamic scripting languages like JavaScript or
VBScript to script the DOM you can simply check
node.nodeType
to find which type of node you have (e.g. 1 for element node, 3 for text
node) and you can always simply use the properties and methods of the
most specialized interface then.
In compiled languages with typed variables however you might need to
cast a node to a specialized class or interface to be able to use the
specialized properties or methods.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
