M
Michael Preminger
Hello!
The question is a bit lengthy (for completeness) but actually quite simple.
I have a very simple xml document Im experimenting with:
<?xml version="1.0"?>
<metadata xmlns="http://purl.org/dc/elements/1.1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dublincore.org/schemas/xmls/simpledc20021212.xsd"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>
UKOLN
</dc:title>
<dc:description>
UKOLN is a national focus of expertise in digital information
management. It provides policy, research and awareness services
to the UK library, information and cultural heritage communities.
UKOLN is based at the University of Bath.
</dc:description>
<dcublisher>
UKOLN, University of Bath
</dcublisher>
<dc:identifier>
http://www.ukoln.ac.uk/
</dc:identifier>
</metadata>
The root element is tagged <metadata>, and I am looping through its
childNodes.
Element docElem=document.getDocumentElement();
System.out.println("Document element: " +
docElem.getNodeName());
NodeList nl=docElem.getChildNodes();
for(int i=0;i<nl.getLength();i++){
Node nd=nl.item(i);
System.out.println(i+" "+nd);
}
Unexpectedly, I get the following output, where every even node seems
devoid of contents.
------------------------------------------------
Document element:metadata
0
1 <dc:title>
UKOLN
</dc:title>
2
3 <dc:description>
UKOLN is a national focus of expertise in digital information
management. It provides policy, research and awareness services
to the UK library, information and cultural heritage communities.
UKOLN is based at the University of Bath.
</dc:description>
4
5 <dcublisher>
UKOLN, University of Bath
</dcublisher>
6
7 <dc:identifier>
http://www.ukoln.ac.uk/
</dc:identifier>
8
---------------------------------------------------------------------------
I thought that the "void" nodes were the text nodes descendent to the
<dc:> elements. (they have a NODE_TYPE 1).
When I descent into one of the nodes (dcublisher) :
if (i==5){
NodeList nl5=nd.getChildNodes();
for(int k=0; k<nl5.getLength(); k++){
System.out.println("k:"+k+" "+nl5.item(k));
}
}
Then I actually get the text "UKOLN, University of Bath".
To me this means that the void even nodes are not the text nodes. (I get
nothing when I try to type-cast them into Text and run getData())
If so: what are they?
If they are the text nodes: Why isnt their content printed to the
standard output
Thanks
Michael
The question is a bit lengthy (for completeness) but actually quite simple.
I have a very simple xml document Im experimenting with:
<?xml version="1.0"?>
<metadata xmlns="http://purl.org/dc/elements/1.1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dublincore.org/schemas/xmls/simpledc20021212.xsd"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>
UKOLN
</dc:title>
<dc:description>
UKOLN is a national focus of expertise in digital information
management. It provides policy, research and awareness services
to the UK library, information and cultural heritage communities.
UKOLN is based at the University of Bath.
</dc:description>
<dcublisher>
UKOLN, University of Bath
</dcublisher>
<dc:identifier>
http://www.ukoln.ac.uk/
</dc:identifier>
</metadata>
The root element is tagged <metadata>, and I am looping through its
childNodes.
Element docElem=document.getDocumentElement();
System.out.println("Document element: " +
docElem.getNodeName());
NodeList nl=docElem.getChildNodes();
for(int i=0;i<nl.getLength();i++){
Node nd=nl.item(i);
System.out.println(i+" "+nd);
}
Unexpectedly, I get the following output, where every even node seems
devoid of contents.
------------------------------------------------
Document element:metadata
0
1 <dc:title>
UKOLN
</dc:title>
2
3 <dc:description>
UKOLN is a national focus of expertise in digital information
management. It provides policy, research and awareness services
to the UK library, information and cultural heritage communities.
UKOLN is based at the University of Bath.
</dc:description>
4
5 <dcublisher>
UKOLN, University of Bath
</dcublisher>
6
7 <dc:identifier>
http://www.ukoln.ac.uk/
</dc:identifier>
8
---------------------------------------------------------------------------
I thought that the "void" nodes were the text nodes descendent to the
<dc:> elements. (they have a NODE_TYPE 1).
When I descent into one of the nodes (dcublisher) :
if (i==5){
NodeList nl5=nd.getChildNodes();
for(int k=0; k<nl5.getLength(); k++){
System.out.println("k:"+k+" "+nl5.item(k));
}
}
Then I actually get the text "UKOLN, University of Bath".
To me this means that the void even nodes are not the text nodes. (I get
nothing when I try to type-cast them into Text and run getData())
If so: what are they?
If they are the text nodes: Why isnt their content printed to the
standard output
Thanks
Michael