want to loop through each apbillpayment and retrieve the value for each paymentkey and amount.
so I have…
VTDDocument doc = new VTDDocument("DATASTREAM1");
List <VTDElement> list = doc.selectNodes("//apbillpayment");
for (VTDElement ex : list)
{
VTDDocument doc1 = new VTDDocument(ex.getText());
List <VTDElement> list1 = doc1.selectNodes("//PAYMENTKEY");
for (VTDElement el : list1)
Unfortunately when I get to the second loop i get the error…
java.lang.Exception: Cannot selectNodes() on an empty document on line #152 -> List list1 = doc1.selectNodes("//PAYMENTKEY");
I thought i needed to use ex.getText() to create the second doc and read from there but clearly it isnt reading it.
Generally if you are doing a “new VTDDocument()” within a loop of parsed XML then you are doing it wrong, unless an XML node itself contains XML as a text string which is unusually rare.
Generally you will only have a single new VTDDocument() at the start of processing, then all operations are performed on that single parsed XML document.