aspose file tools*
The moose likes XML and Related Technologies and the fly likes Problems trying to print all nodes from an XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problems trying to print all nodes from an XML" Watch "Problems trying to print all nodes from an XML" New topic
Author

Problems trying to print all nodes from an XML

Alba Garcia
Greenhorn

Joined: Jun 09, 2014
Posts: 11
I confused.

I have this "xml" String:


But when I try to process it to print all their nodes with this Java code


I only get this:


What may I be doing wrong?

Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18904
    
    8

When you ask about "printing" a node, exactly what do you expect to see?
Alba Garcia
Greenhorn

Joined: Jun 09, 2014
Posts: 11
In this case I would like to print for example the patient information:



patient:
  • extension
  • birthTime
  • William Brogden
    Author and all-around good cowpoke
    Rancher

    Joined: Mar 22, 2000
    Posts: 12823
        
        5
    You should get familar with the table in the org.w3c.dom.Node interface JavaDocs.

    It shows what various Node types have for nodeValue and nodeName - sometimes surprising.

    Bill
    William Brogden
    Author and all-around good cowpoke
    Rancher

    Joined: Mar 22, 2000
    Posts: 12823
        
        5
    I suggest your next step in learning XML processing with the Java standard library would be to
    print the count of nodes in the childNodes NodeList, then iterate printing the nodeName and
    nodeValue for each.

    This should show what the call to getChildNodes() is actually returning.

    Bill
    Alba Garcia
    Greenhorn

    Joined: Jun 09, 2014
    Posts: 11
    Thank you very much!!!

    Now I have this code



    And when I get this in the "xml" var:


    I can see this in my Java Console:


    Weird but interesting!!

     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Problems trying to print all nodes from an XML