• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems trying to print all nodes from an XML

 
Alba Garcia
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21113
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you ask about "printing" a node, exactly what do you expect to see?
 
Alba Garcia
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 13064
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 13064
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 11
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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!!

     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic