XML : How to get values from child nodes using java?

I have a XML content like below...

  <Parent_Tag>            <Parent_Tag_1>              <Component>                <Type>ABC</Type>                <Amount>                  <Value_1>0.1</Value_1>                  <Value_2>AAA</Value_2>                </Amount>              </Component>            </Parent_Tag_1>            <Parent_Tag_2>              <Item>                <Item_1>                  <Component>                    <Type>CCC</Type>                    <Amount>                      <Value_1>0.1</Value_1>                      <Value_2>BB</Value_2>                    </Amount>                  </Component>                  <Component>                    <Type>BBB</Type>                    <Amount>                      <Value_1>2.0</Value_1>                      <Value_2>AA</Value_2>                    </Amount>                  </Component>                </Item_1>                           </Item>            </Parent_Tag_2>                 </Parent_Tag>    

I need to get the values in tag Component under Parent_Tag_1. But my code gave all the component tags under Parent_Tag. How to fix this ??

Please give a suggestion...

No comments:

Post a Comment