Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Parsing xml doc

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
DocumentBuilderFactory factory = null;
DocumentBuilder builder;
Document doc = null;
String query = "";
factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
builder = this.factory.newDocumentBuilder();
doc = this.builder.parse(http_url);

XPathFactory xFactory = XPathFactory.newInstance();


XPath xpath = xFactory.newXPath();
this.expr = xpath.compile(query);
Object result = this.expr.evaluate(this.doc, XPathConstants.NODESET);
NodeList nodes = (NodeList)result;
for (int i = 0; i < nodes.getLength(); )
{
Attr houseAttr = (Attr)nodes.item(i);
}

You might also like