nike
nike

Reputation: 13

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.

Upvotes: 0

Views: 47

Answers (2)

greenPadawan
greenPadawan

Reputation: 1571

You should fetch only the "Frame" tags using doc.getElementsByTagName("frame") and then print the value of their child "Material" tags.

Upvotes: 1

mbmast
mbmast

Reputation: 1100

frameList= doc.getElementsByTagName("material");

Should be

frameList= doc.getElementsByTagName("frame");

Upvotes: 0

Related Questions