N
Nik
I have my xml file which looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
- <enatureArchiver>
- <archive name="music">
- <disc name="mp3">
- <file name="Audioplacid - Heaven 0.9.1.mp3">
<size>11911528</size>
<subpath>D:\Mp3</subpath>
<ext>mp3</ext>
<added>1112185739331</added>
<disc>mp3</disc>
<comment />
<rating />
<hidden />
</file>
- <file name="Audioplacid - Heaven 0.9.mp3">
<size>11974128</size>
<subpath>D:\Mp3</subpath>
<ext>mp3</ext>
<added>1111497873734</added>
<disc>mp3</disc>
<comment />
<rating />
<hidden />
</file>
....
what I wanna do now is to read:
- all the "file" attributes
- only the ones within the "archive" tag with the attribute "music"
- only the ones within the "disc" tag with the attribute "mp3"
(there are different attributes of the disc and archive tag)
unfortunately I could not make this to work. I could not find out how I
can go deeper down in the tree.
here is the code I have so far:
<JAVA>
xmldoc = BasicDom.parseXmlFile(XMLFILE,false);
// Get a list of all elements in the document
NodeList list = xmldoc.getElementsByTagName("*");
for (int i=0; i<list.getLength(); i++) {
// Get element
Element element = (Element)list.item(i);
if(element.getTagName().equals("archive"))
{
System.out.print(element.getAttribute("name"));
}
}
</JAVA>
thanks in advance for any help or advise.
<?xml version="1.0" encoding="UTF-8" ?>
- <enatureArchiver>
- <archive name="music">
- <disc name="mp3">
- <file name="Audioplacid - Heaven 0.9.1.mp3">
<size>11911528</size>
<subpath>D:\Mp3</subpath>
<ext>mp3</ext>
<added>1112185739331</added>
<disc>mp3</disc>
<comment />
<rating />
<hidden />
</file>
- <file name="Audioplacid - Heaven 0.9.mp3">
<size>11974128</size>
<subpath>D:\Mp3</subpath>
<ext>mp3</ext>
<added>1111497873734</added>
<disc>mp3</disc>
<comment />
<rating />
<hidden />
</file>
....
what I wanna do now is to read:
- all the "file" attributes
- only the ones within the "archive" tag with the attribute "music"
- only the ones within the "disc" tag with the attribute "mp3"
(there are different attributes of the disc and archive tag)
unfortunately I could not make this to work. I could not find out how I
can go deeper down in the tree.
here is the code I have so far:
<JAVA>
xmldoc = BasicDom.parseXmlFile(XMLFILE,false);
// Get a list of all elements in the document
NodeList list = xmldoc.getElementsByTagName("*");
for (int i=0; i<list.getLength(); i++) {
// Get element
Element element = (Element)list.item(i);
if(element.getTagName().equals("archive"))
{
System.out.print(element.getAttribute("name"));
}
}
</JAVA>
thanks in advance for any help or advise.