java - How to filter xml nodes based on filter in xpath -
i have xml need apply filter filter out nodes
. filter criteria sent client via request xml using xpath
notation
ie. objectdata[vdata[@destcode = beanr0170100497]]
when reply client need filter , send above data. can jaxb
or other simple parser
? sample highly appreciate.
xpath built default api, example...
documentbuilderfactory dbf = documentbuilderfactory.newinstance(); document doc = dbf.newdocumentbuilder().parse(...); xpathfactory xf = xpathfactory.newinstance(); xpath xpath = xf.newxpath(); string query = ... xpathexpression xexp = xpath.compile(query); nodelist nl = (nodelist) xexp.evaluate(doc, xpathconstants.nodeset); (int index = 0; index < nl.getlength(); index++) { node node = nl.item(index); system.out.println(node.gettextcontent()); }
Comments
Post a Comment