Hi,
I quite new to Javascript and XML. Here a is snippet of my XML file.
[CODE=xml]<xml>
<cd>
<rock>
<item id='1'>
<name>Bon Jovi</name>
<price>$10</price>
<description>ab c</description>
</item>
<item id='2'>
<name>U2</name>
<price>$11</price>
<description>ab c</description>
</item>
<item id='3'>
<name>Linkin Park</name>
<price>$12</price>
<description>ab c</description>
</item>
</rock>
<pop>
<item id='1'>
<name>Nelly</name>
<price>$5</price>
<description>ab c</description>
</item>
<item id='2'>
<name>Justin</name>
<price>$5</price>
<description>ab c</description>
</item>
</pop>
</cd>
</xml>
[/CODE]
I am working with javascript.
Basically I have 2 problems.
1. How do I just get the 'name' from all the items in <rock> tags?
2. How do I get the the 'name' from a specific position node? For example, I want to get the name of the artist in <rock> from node 1 onwards. -> Expected output: U2, Linkin Park.
Thanks so much in advance.
Regards,
Gordon
I quite new to Javascript and XML. Here a is snippet of my XML file.
[CODE=xml]<xml>
<cd>
<rock>
<item id='1'>
<name>Bon Jovi</name>
<price>$10</price>
<description>ab c</description>
</item>
<item id='2'>
<name>U2</name>
<price>$11</price>
<description>ab c</description>
</item>
<item id='3'>
<name>Linkin Park</name>
<price>$12</price>
<description>ab c</description>
</item>
</rock>
<pop>
<item id='1'>
<name>Nelly</name>
<price>$5</price>
<description>ab c</description>
</item>
<item id='2'>
<name>Justin</name>
<price>$5</price>
<description>ab c</description>
</item>
</pop>
</cd>
</xml>
[/CODE]
I am working with javascript.
Basically I have 2 problems.
1. How do I just get the 'name' from all the items in <rock> tags?
2. How do I get the the 'name' from a specific position node? For example, I want to get the name of the artist in <rock> from node 1 onwards. -> Expected output: U2, Linkin Park.
Thanks so much in advance.
Regards,
Gordon
Comment