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.

In reply to Re: how does XML::DOM loadXML? by anirudh_sml
in thread how does XML::DOM loadXML? by ashwani

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.