java - How to get attribute value? DomParser -


this question has answer here:

i have method:

 private static void print(nodelist nodelist) {      (int = 0; < nodelist.getlength(); i++) {         node t = nodelist.item(i);          if (t.getnodetype() == node.element_node) {             system.out.println("node: " + t.getnodename());             system.out.println("values " + t.gettextcontent());             system.out.println("------------------------------");         }            if (doc.haschildnodes()) {             print(t.getchildnodes());         }     }  } 

it displays contents of xml document:

<card>         <thema>people</thema>         <type sent="true">advertising</type>         <country>india</country>         <year>1966</year>         <authors><author>julia</author></authors>         <valuable>historical</valuable>     </card> 

but not show value of attribute in node "sent". how can modify it? thanks!

use method getattributes list of attributes of node:

a namednodemap containing attributes of node (if element) or null otherwise.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -