Results 1 to 1 of 1
- 04-03-2011, 02:15 AM #1Member
- Join Date
- Apr 2011
- Rep Power
parsing an xml file and executing an XPATH querry
I have an xml file
My goal is displayed only the part when the text is equal. This code display all the file
if i try this code, it doesn't work
XPath xpath = XPathFactory.newInstance().newXPath(); String expression = "/postes/poste"; InputSource inputSource = new InputSource("postes.txt"); Node nodes =(Node) xpath.evaluate(expression, inputSource, XPathConstants.NODE);
and if i try this code
XPathFactory xPathFactory = XPathFactory.newInstance(); // To get an instance of the XPathFactory object itself. XPath xPath = xPathFactory.newXPath(); // Create an instance of XPath from the factory class. String expression = "/postes/poste[gouvernorat=text]"; XPathExpression xPathExpression = xPath.compile(expression); // Compile the expression to get a XPathExpression object. Object result = xPathExpression.evaluate(R.raw.postes); //Evaluate the expression against the XML Document to get the result.
i added this import javax.xml.xpath.*;
but it doesn't work
I Try DOM Parser but it doesn't work also ; i can't read the file
please help me
Thank you in advance.
Last edited by fassfouss; 04-03-2011 at 09:41 PM.
- By ziggy in forum New To JavaReplies: 7Last Post: 02-27-2011, 01:55 PM
- By misha680 in forum XMLReplies: 0Last Post: 05-12-2010, 12:11 PM
- By thooom in forum XMLReplies: 6Last Post: 04-26-2010, 10:47 AM
- By thooom in forum New To JavaReplies: 6Last Post: 04-25-2010, 05:56 PM
- By yuyu200 in forum XMLReplies: 0Last Post: 11-13-2009, 10:51 PM