parsing xml to find elements in java

邮差的信 提交于 2019-12-11 13:07:01

问题


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>

回答1:


document.getElementsByTagName("*");

matches all elements.

See javadocs.



来源:https://stackoverflow.com/questions/4713922/parsing-xml-to-find-elements-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!