Here is a XML:
<mesh>
<triangles material="face" count="990">
<input semantic="VERTEX" source="#boyShape-skin-vertices" offset="0"/>
<input semantic="NORMAL" source="#boyShape-skin-normals" offset="1"/>
<input semantic="TEXCOORD" source="#boyShape-skin-map-channel1" offset="2" set="1"/>
<p>45 56 44 61 57 45 58 58 46 58 58 46 65 59 47 45 56 44 46 60 48 67 61 49 58 58 46 58 58 46 61 57 45 46 60 48 49 62 50 66 63 51 </p>
</triangles>
<triangles material="face" count="1320">
<input semantic="VERTEX" source="#boyShape-skin-vertices" offset="0"/>
<input semantic="NORMAL" source="#boyShape-skin-normals" offset="1"/>
<input semantic="TEXCOORD" source="#boyShape-skin-map-channel1" offset="2" set="1"/>
<p>45 46 60 48 49 62 50 66 63 51 45 56 44 61 57 45 58 58 46 58 58 46 65 59 47 45 56 44 46 60 48 67 61 49 58 58 46 58 58 46 61 57 45 46 60 48 49 62 50 66 63 51 </p>
</triangles>
<triangles material="face" count="1540">
<input semantic="VERTEX" source="#boyShape-skin-vertices" offset="0"/>
<input semantic="NORMAL" source="#boyShape-skin-normals" offset="1"/>
<input semantic="TEXCOORD" source="#boyShape-skin-map-channel1" offset="2" set="1"/>
<p>58 46 58 58 46 65 59 47 45 56 44 61 57 45 58 58 46 58 58 46 65 59 47 45 56 44 46 60 48 67 61 49 58 58 46 58 58 46 61 57 45 46 60 48 49 62 50 66 63 51 </p>
</triangles>
</mesh>
Java code is
for(int s=0; s<mesh.getLength() ; s++){
Node firstPersonNode = mesh.item(s);
System.out.println(mesh.item(s).getNodeName() + " Test");
if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){
Element firstPersonElement = (Element)firstPersonNode;
NodeList source = firstPersonElement.getElementsByTagName("triangles");
System.out.println(source.getLength() + "Source Length");
Node firstsource = source.item(1); // triangles index given here
if(firstsource.getNodeType() == Node.ELEMENT_NODE){
Element firstPersonElement1 = (Element)firstsource;
System.out.println(firstPersonElement1.getAttribute("id") + " --> <-- ");
NodeList floatarray = firstPersonElement1.getElementsByTagName("p");
Element firstNameElement = (Element)floatarray.item(0);
NodeList textFNList = firstNameElement.getChildNodes();
System.out.println("Vertexes : " + ((Node)textFNList.item(0)).getNodeValue().trim());
}
}
}
I am trying to parse the input and p which lies inside triangles node but, I have a problem.
The problem is when I specify the index as 1 in the above mentioned code all the child nodes are getting detected and gets parsed. other than 1 it doesn’t even detect the child nodes input and p. What may be the problem? Please help me to resolve this issue.
Here is how you can parse your document using the DOM API: