How to Read All Attributes of an Element in VTD-XML?
There are two ways to read all the attribute values of an element node.
The first one is to use XPath expression @* as in the example below
ap = new AutoPilot (vn);
ap.selectXPath(“@*”);
int i=-1;
while((i=ap.evalXPath())!=-1){
// i will be attr name, i+1 will be attribute value
}
The second is lighter weight, which is by directly using autoPilot’s selectAttr() and iterAttr()
ap = new AutoPilot(vn);
ap.selectAttr(“*”);
int i=-1;
while((i=ap.iterateAttr())!=-1){
// i will be attr name, i+1 will be attribute value
}
Advertisement
what if I want to have one element’s all attribute values read into a linkedlist and have that element’s sibling’s all attribute values read into another linkedlist? How can i implement this requirement? looking forward to your reply!
how to construct a list is not something vtd-xml offers, you have to do it yourself. To access all attributes, just instantiate autoPilot and select attr() and iterateAttr()