<?xml version="1.0" encoding="UTF-8"?>
-<ADOXML adoversion="Version 5.1" username="kvarga" database="adonisdb" time="08:55" date="30.11.2013" version="3.1">
-<MODELS>
-<MODEL version="" applib="ADONIS BPMS BP Library 5.1" libtype="bp" modeltype="Business process model" name="Product development" id="mod.25602">
-<MODELATTRIBUTES>
<ATTRIBUTE name="Version number" type="STRING"> </ATTRIBUTE>
<ATTRIBUTE name="Author" type="STRING">kvarga</ATTRIBUTE>
<ATTRIBUTE name="Creation date" type="STRING">2013-11-30, 08:50</ATTRIBUTE>
<ATTRIBUTE name="Date last changed" type="STRING">2013-11-30, 08:54:46</ATTRIBUTE>
-<INSTANCE name="Business Opportunities census" id="obj.25615" class="Activity">
<ATTRIBUTE name="Position" type="STRING">NODE x:6.5cm y:10.5cm index:7</ATTRIBUTE>
<ATTRIBUTE name="External tool coupling" type="STRING"> </ATTRIBUTE>
<ATTRIBUTE name="Description" type="STRING">I WANT THIS PARA 1</ATTRIBUTE>
<ATTRIBUTE name="Version number" type="STRING"> </ATTRIBUTE>
<ATTRIBUTE name="Author" type="STRING">kvarga</ATTRIBUTE>
<ATTRIBUTE name="Creation date" type="STRING">2013-11-30, 08:50</ATTRIBUTE>
<ATTRIBUTE name="Date last changed" type="STRING">2013-11-30, 08:54:46</ATTRIBUTE>
-<INSTANCE name="Business Opportunities census" id="obj.25615" class="Vess">
<ATTRIBUTE name="Position" type="STRING">NODE x:6.5cm y:10.5cm index:7</ATTRIBUTE>
<ATTRIBUTE name="Description" type="STRING">I DONT WANT THIS PARA 2</ATTRIBUTE>
</INSTANCE>
</MODEL>
</MODELS>
</ADOXML>
hey there i am new to xml read! Actually what i need is to read the above kind a xml file so that to get the text
I WANT THIS PARA 1
i need to obtain only this text my xpath query is:
String expression = "/ADOXML/MODELS/MODEL/INSTANCE/ATTRIBUTE[@name='Description' and @type='STRING']";
But my query gives me the result as:
I WANT THIS PARA 1
I DONT WANT THIS PARA 2 //this line i dont want
so the problem is to only read inside the attribute tag whose name is description and type is string but its paraent tag should be instance and its class should be activity!
I am using this code:
String expression = "/ADOXML/MODELS/MODEL/INSTANCE/ATTRIBUTE[@name='Description' and @type='STRING']";
NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(document, XPathConstants.NODESET);
ArrayList<String> text = new ArrayList<String>();
int k;
for (k = 0; k < nodeList.getLength(); k++) {
String txt=nodeList.item(k).getTextContent();
txt=txt.replace("[","").replace("]","").replace("#","").replace(":", "").replace("•", "").replace("\n", " ")
.replace("\u0092", " ").replace("'", "").replace("•", " ").replace("-", " ").replace("’", " ").replace("\n", " ");
text.add(txt);
}