Given the following xml:
<JUT>
<DDT>
<SSG q="textGoal">Lorem ipsum...</SSG>
</DDT>
....
...
</JUT>
I am using vtd-xml with XPath in order to retrieve '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:
Regards
Use vn.getAttributeVal(vn.toString(node))
Another way of doing it is
vn.toString(node+1)
assuming node is not -1. As to the URL escaping, part, you have toString()
, toRawString()
, and toNormalizedString()
to choose from
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With