android - Removing XML node Using Xpath -


I am trying to delete some nodes from the XML document but XML is not working here

  & lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; reg> & Lt; Users & gt; & Lt; Name & gt; Adik & lt; / Name & gt; & Lt; Email & gt; adil@mail.com< / Email & gt; & Lt; Picture & gt; /storage/sdcard0/XLEZData/EZImage/20130425163759.PNG< / Pictures & gt; & Lt; Last Adrated & gt; 7 April 2014 09:28 28: 27 & lt; / Last Edit & gt; & Lt; / User & gt; & Lt; Users & gt; & Lt; Name & gt; Adil & lt; / Name & gt; & Lt; Email & gt; adil123@mail.com< / Email & gt; & Lt; Picture & gt; / Storage / sdcard0 / DCIM / camera / 20140318_165923 (0) .jpg & lt; / Pictures & gt; & Lt; Last Adrated & gt; 7 April 2014 09: 29: 06 & lt; / Last Edit & gt; & Lt; / User & gt; & Lt; / Reg>   

And here is the code

  Private Zero DeleteRecord (string sEmail) {try //// DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance (); Document document = dbf.newDocumentBuilder (). Parse (new file (environment .getExternalStorageDirectory (+ "/ / reginue / output / data.xml")); XPathFactory xpf = XPathFactory.newInstance (); XPath xpath = xpf.newXPath (); XPathExpression expression = xpath.compile ("//reg / user [email = '" + e-mail +' '] "); Logs. V ("expression", expression .to string ()); Node b13 node = (node) expression. Evaluation (document, XPathConstants.NODE); b13Node.getParentNode () removeChild (b13Node). Try {transformerffecture tf = transformerfacture.New instance (); Transformer T = TF Nuu Transformers (); T. Transformform (new dosource (document), new stream result (system out)); } Hold (exception e) {} ////} hold (FileNotFoundException e) {e.printStackTrace (); } Catch (SAXException e) {e.printStackTrace (); } Hold (IOException e) {e.printStackTrace (); } Hold (parser configuration exception e) {e.printStackTrace (); } Catch (XPathExpressionException e) {e.printStackTrace (); }}   

What do I want the entire user node to have an email name with their children, the last edit and picture

Try xpath.compile (" //reg / user [email = '"+ + + +"'] "); .

How to use the JAXP XPath API with Namespace to select nodes in namespace if XML names have namespace.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -