i2ijeya
i2ijeya

Reputation: 16410

parsing xml to find elements in java

I have to parse an xml document and have to get all the elements in the same. I have gone through example, where they are just providing the element name. I do not want to give the element name manually. So how could I get all the elements? I am having only the method name getElementsByTagName(elementName). Is there any other method to get the elements?

<bookmap>
<booktitle>
    <mainbooktitle>GMAT in a BOX </mainbooktitle>
</booktitle>
<frontmatter>
    <notices href="Topics/ref_GMAT_box_notices.dita"/>
        <topicref href="Topics/con_GMAT_box_instructions.dita"/>
</frontmatter>
<chapter href="comp_verbal.ditamap" format="ditamap"/>
<chapter href="comp_math.ditamap" format="ditamap"/>
</bookmap>

Upvotes: 1

Views: 2604

Answers (1)

dogbane
dogbane

Reputation: 274612

document.getElementsByTagName("*");

matches all elements.

See javadocs.

Upvotes: 2

Related Questions