Lorem ipsum... .... ... <...">

Getting attribute text in xml using vtd-xml in java

Given the following xml:

<JUT> <DDT> <SSG q="textGoal">Lorem ipsum...</SSG> </DDT> .... ... </JUT> 

I am using vtd-xml with XPath to get "textGoal" as follows:

  VTDGen vg = new VTDGen(); vg.setDoc(xmlContent); vg.parse(false); VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); int node = 0; ap.selectXPath("//SSG[1]/@q"); node = ap.evalXPath(); if(node != -1) { myString = vn.toString(node); } 

This gives myString as "q" and not "textGoal". I have two questions:

  • What am I doing wrong?
  • I know that "textGoal" has URL escaping. Does Vtd-xml make URL-UNescape or do I need to do it myself?

Hello

+4
source share
2 answers

Use vn.getAttributeVal(vn.toString(node))

+5
source

Another way to do this:

 vn.toString(node+1) 

Assuming node is not equal to -1. As for scrolling the url, you have toString() , toRawString() and toNormalizedString() to choose from

+2
source

All Articles