VTD Doc help - select nested data

I am reading through data and parsing out a list of invoices. below is an example of one invoice

							<billCodeDescription><![CDATA[GROSS WAGES]]></billCodeDescription>
							<billCodeDescription><![CDATA[WORKERS COMPENSATION]]></billCodeDescription>
							<billCodeDescription><![CDATA[ADMINISTRATIVE FEE]]></billCodeDescription>

Each invoice has a few fields that I am grabbing and also the sumbilling section.

Grabbing each node (batchnumber, invoice, client id, etc) no problem using selectSingleNode.

List <VTDElement> list = doc.selectNodes("root/clientsWithVouchers/billingClient/e/root/e");
for (VTDElement ex : list)
    VTDElement elBatch = ex.selectSingleNode("batchNumber");
    VTDElement elInvoice = ex.selectSingleNode("invoice");
    VTDElement elDate = ex.selectSingleNode("payDate");
    VTDElement elClient = ex.selectSingleNode("client_ID");
    VTDElement elLocation = ex.selectSingleNode("location");

    String strBatch = elBatch == null ? "" : elBatch.getText();
    String strInvoice = elInvoice == null ? "" : elInvoice.getText();
    String strDate = elDate == null ? "" : elDate.getText();
    String strClient = elClient == null ? "" : elClient.getText();
    String strLocation = elLocation == null ? "" : elLocation.getText();

but I also want to grab the entire sumBilling node and all of its data. If I use selectSingleNode like above, I retrieve no data. I assume it only grabs the value of that node and not any children. What would be the proper way to retrieve the entire sumBilling node?


You have to select each row under sumBilling as a list, just like is done in your outer loop.

Something like:

List<VTDElement> listChildren = ex.selectNodes("sumBilling/e");

Ok. So there isn’t a way to grab the entire sumbilling node and all its children in one?

I don’t think so, no.

ok. I works by looping through each of the sumbilling/e just trying to be more efficient since I want everything that is under the sumBilling.