I have an XML file and want to read the information using XPath, I want to read the 'listings_Id' and 'budget_remaining' together.
XML example
<ads>
<ad>
<listing_ids>
<listing_id>2235</listing_id>
<listing_id>303</listing_id>
<listing_id>394</listing_id>
</listing_ids>
<reference_id>11</reference_id>
<net_ppe>0.55</net_ppe>
<budget_remaining>50000.0</budget_remaining>
</ad>
<ad>
<listing_ids>
<listing_id>2896</listing_id>
</listing_ids>
<reference_id>8</reference_id>
<net_ppe>1.5</net_ppe>
<budget_remaining>1.3933399</budget_remaining>
</ad>
</ads>
I want to output it to a CSV file as the following
ListingId,BudgetRemaining
2235,0.55
303,0.55
394,0.5
2896,1.5
I am trying to use the example as
DataReader reader = new XmlReader(new File("links.xml"))
.addField("ListingId", "//ad/listing_ids/listing_id")
.addField("BudgetRemaining", "//ad/budget_remaining")
.addRecordBreak("//ad")
.setExpandDuplicateFields(true);
But it seems so I cannot find the jar file for XMLReader and DataReader and also I am going definitely wrong with the format. New to Java, please any help is appreciated.