XPATH in Android
<p>I have an xml file</p>

<p>XMLParsing.java read all the file XML</p>

<p>My goal is displayed only the part when the text is equal. This code display all the file</p>

<p>if i try this code, it doesn't work</p>

<pre><code>    XPath xpath = XPathFactory.newInstance().newXPath();
    String expression = "/postes/poste";
    InputSource inputSource = new InputSource("postes.txt");
    Node nodes =(Node) xpath.evaluate(expression, inputSource, XPathConstants.NODE);
</code></pre>

<p>the error message is on this line <code>Node nodes =(Node) xpath.evaluate(expression, inputSource, XPathConstants.NODE)</code>; <code>inputSource can not be resolved</code></p>

<p>and if i try this code</p>

<pre><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.
</code></pre>

<p>The error is in to lines <code>xPath.compile(expression);</code> and <code>xPathExpression.evaluate(R.raw.postes);</code></p>

<p>i added this <code>import javax.xml.xpath.*;</code></p>

<p>but it doesn't work</p>

<p>I Try DOM Parser but it doesn't work also ; i can't read the file</p>

<p>please help me</p>

<p>Thank you in advance.</p>
