简体   繁体   中英

Reading XML data using DOM in Java

I am trying to get data from the below XML.

    <vehicle>
        <id>vehicle</id>
        <frame>
            <material>plastic</material>

When I read the data from the frame tag, how do i get the value of frame tag.

您应该使用doc.getElementsByTagName(“ frame”)仅获取“ Frame”标签,然后打印其子“ Material”标签的值。

frameList= doc.getElementsByTagName("material");

应该

frameList= doc.getElementsByTagName("frame");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM