XML parse returns null for some tags
===

I was trying to parse some xml files which are generated by 3ds max and maya. Everything works fine but some values are returned null. For example concider below (collada with .dae extension) xml generated by max or maya ,

      <triangles>
       <p>  234 32 4 23 544 35 43 5 435</p>
      </triangles>
      <triangles>
       <p> 43543 45 34 5 12 34 4 36457 6</p>
      </triangles>
      <triangles>
       <p>2345  325 34 543 5 34 534 5 435</p>
      </triangles>

Now when I parse using the java code(i'll provide if needed),

 The output is:

    p has 234 32 4 23 544 35 43 5 435
    p has 
    p has 2345  325 34 543 5 34 534 5 435 

The second line of output shows nothing even if there is a value. Now, If I edit the line by myself the output is as expected i.e,  the output is shown below Here I have given my own values in the xml file.

   The edited xml is

     <triangles>
       <p>  234 32 4 23 544 35 43 5 435</p>
      </triangles>
      <triangles>
       <p> 28 234  34 32 4 23 4 23 423  43</p>
      </triangles>
      <triangles>
       <p>2345  325 34 543 5 34 534 5 435</p>
      </triangles>

Output is:

    p has 234 32 4 23 544 35 43 5 435
    p has 28 234  34 32 4 23 4 23 423  43
    p has 2345  325 34 543 5 34 534 5 435 

Above I have explained the problem I am facing. [Here][1] you can find the file which is generated by maya. The java code which I have used is given below.

     
    import java.io.File;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    
    public class Main {
    
    	public static void main(String args[]) {		
    	
    		try {
    
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                Document doc = docBuilder.parse (new File("d://tablemaya.dae"));
    
                // normalize text representation
                doc.getDocumentElement ().normalize ();
                System.out.println ("Root element of the doc is " + 
                     doc.getDocumentElement().getNodeName());
    
    
                NodeList listOfPersons = doc.getElementsByTagName("library_geometries");
                int totalPersons = listOfPersons.getLength();
                System.out.println("Total no of people : " + totalPersons);
                Node firstPersonNode = listOfPersons.item(0);
                if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){
    
    
                    Element firstPersonElement = (Element)firstPersonNode;
    
                    //-------
                    NodeList geometrylist = firstPersonElement.getElementsByTagName("geometry");
                    System.out.println(geometrylist.getLength() + " Geometry size");
                    for(int k=0;k<geometrylist.getLength();k++) {
    	                Element geometryItr = (Element)geometrylist.item(k);
    	
    	                NodeList meshlist = geometryItr.getElementsByTagName("mesh");
    	                
    	                System.out.println("Mesh length is " + meshlist.getLength());
    	                
    
    	                for(int k1=0;k1<meshlist.getLength();k1++) {
    	                	Element geometryItr1 = (Element)meshlist.item(k1);
    	                	
    		                NodeList meshlist1 = geometryItr1.getElementsByTagName("source");
    		                
    		                System.out.println("Source length is " + meshlist1.getLength());	                	
    	                }
    					for(int k2=0;k2<meshlist.getLength();k2++) {
    						Element geometryItr1 = (Element)meshlist.item(k2);
    						
    					    NodeList trianglelist = geometryItr1.getElementsByTagName("triangles");
    					    
    					    //System.out.println("Triangles length is " + trianglelist.getLength());	 
    					  
    					        for(int o=0;o<trianglelist.getLength();o++) {
    					        	
    					        	Element trichildnodes = (Element) trianglelist.item(o);
    					        	NodeList inputs = trichildnodes.getElementsByTagName("input");
    					    	NodeList p = trichildnodes.getElementsByTagName("p");
    					    	//System.out.println("Fucking Problem " + p.item(0).getFirstChild().getNodeValue());
    					    	Element ppp = (Element) p.item(0);
    					    	//System.out.println("Node Value " + ppp.getNodeValue());
    					    	System.out.println(inputs.getLength() + "Input length");
    					    	
    					    	for(int in=0;in<inputs.getLength();in++) {
    					    		
    					    		Element inn = (Element) inputs.item(in);
    					    		System.out.println(inn.getAttribute("semantic") + " " + inn.getAttribute("source") + " Attributes");
    					    		
    					    	}
    					    	
    					    	for(int i=0; i<p.getLength(); i++) {
    						        Element e = (Element)p.item(i);  
    						        String ss = e.getFirstChild().getTextContent();
    						        System.out.println("Noide is " + ss);
    						    }
    					    	//System.out.println(p.getLength() +  " P's length" );
    							//System.out.println("P's content " + ppp.getFirstChild().getNodeValue());
    					    	
    					    	
    					    }
    					    
    					    
    					}
    	                for(int k1=0;k1<meshlist.getLength();k1++) {
    	                	Element geometryItr1 = (Element)meshlist.item(k1);
    	                	
    		                NodeList meshlist1 = geometryItr1.getElementsByTagName("vertices");
    		                
    		                System.out.println("Vertices length is " + meshlist1.getLength());	                	
    	                }
    	                
    	                
                    }
    
                }
                
                
            }catch (Exception err) {
            	err.printStackTrace();
            }
    		
    	}
    	
    }


       
  [1]: http://purple-works.com/yardstick/tablemaya.dae

 I am unable to get all the contents of `<p>`. What may be the problem is it with my code or with xml? Please some one help me with this regard. Thank for reading my question.


Vinay