in reply to how does XML::DOM loadXML?

XML::DOM is based on XML::Parser, and offers a SAX interface. It is distributed as part of the libxml-enno bundle. Being widely used, it is probably one of the most robust XML modules.
There are different nodes in this module as
The following predefined constants indicate which type of node it is.
UNKNOWN_NODE (0) The node type is unknown (not part of DO +M) ELEMENT_NODE (1) The node is an Element. ATTRIBUTE_NODE (2) The node is an Attr. TEXT_NODE (3) The node is a Text node. CDATA_SECTION_NODE (4) The node is a CDATASection. ENTITY_REFERENCE_NODE (5) The node is an EntityReference. ENTITY_NODE (6) The node is an Entity. PROCESSING_INSTRUCTION_NODE (7) The node is a ProcessingInstruction. COMMENT_NODE (8) The node is a Comment. DOCUMENT_NODE (9) The node is a Document. DOCUMENT_TYPE_NODE (10) The node is a DocumentType. DOCUMENT_FRAGMENT_NODE (11) The node is a DocumentFragment. NOTATION_NODE (12) The node is a Notation. ELEMENT_DECL_NODE (13) The node is an ElementDecl (not part +of DOM) ATT_DEF_NODE (14) The node is an AttDef (not part of DO +M) XML_DECL_NODE (15) The node is an XMLDecl (not part of D +OM) ATTLIST_DECL_NODE (16) The node is an AttlistDecl (not part +of DOM) Usage: if ($node->getNodeType == ELEMENT_NODE) { print "It's an Element"; }
Different methods are used in this module and when the method is called in a list context (for example) , it returns a regular perl list containing the result nodes. E.g.
@list = $node->getElementsByTagName("tag"); # returns a perl li +st $nodelist = $node->getElementsByTagName("tag"); # returns a NodeLis +t (object ref.) for my $elem ($node->getElementsByTagName("tag")) # iterate over the +result nodes
Please use this example i think this will help you.