How to convert string to xml file in java -


 <?xml version="1.0" encoding="utf-8"?><soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"><soap:body><loginresponse xmlns="http://tempuri.org/questiphonewebservice/questiphonewebservice"><loginresult>&lt;return_value&gt;&lt;error result= '-1' desc = 'the password entered system not valid. please check password , try again.'/&gt;&lt;/return_value&gt;</loginresult></loginresponse></soap:body></soap:envelope> 

hi getting value webservices. want convert above string xml can tell how convert string xml file in java

<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body> <loginresponse xmlns="http://tempuri.org/questiphonewebservice/questiphonewebservice"> <loginresult> &lt;root xmlns:sql="urn:schemas-microsoft-com:xml-sql"&gt;&lt;login_details user_id="testpub2" company_id="1" user_name=" aaa" system_user_id="6976" user_email_id="hcltestpub2@hsdlgsdmnk0098.com" token_string="a93805f1f1c340f5a8155fdd9b77e595" disclaimer_agreed="1" user_enabled="1" user_company_enabled="1" user_type="2" login_expiry_days="999" token_creation_date="2010-10-01t16:04:26" mobile_enabled="1" user_company_mobile_enabled="1"/&gt;&lt;company_details client_type_id="8"/&gt;&lt;user_settings&gt;&lt;quest_group id="14293" name="world" assign_num="14"/&gt;&lt;index_provider id="14251" name="quest (default)"/&gt;&lt;stock_identifier id="57" name="ticker"/&gt;&lt;/user_settings&gt;&lt;permissions&gt;&lt;quest_functions&gt;&lt;function name="charting" id="501" access="1"/&gt;&lt;function name="modeller" id="512" access="1"/&gt;&lt;function name="momentum" id="513" access="1"/&gt;&lt;function name="portfolio" id="516" access="1"/&gt;&lt;function name="search" id="518" access="1"/&gt;&lt;function name="sensitivity" id="521" access="1"/&gt;&lt;function name="statistics" id="524" access="1"/&gt;&lt;function name="strategy" id="525" access="1"/&gt;&lt;function name="summary" id="526" access="1"/&gt;&lt;function name="triangle" id="528" access="1"/&gt;&lt;function name="valuation" id="529" access="1"/&gt;&lt;function name="commentary" id="530" access="1"/&gt;&lt;function name="citn" id="534" access="1"/&gt;&lt;function name="batch report" id="553" access="1"/&gt;&lt;function name="modellerws" id="557" access="1"/&gt;&lt;function name="sector analysis" id="562" access="1"/&gt;&lt;/quest_functions&gt;&lt;admin_functions&gt;&lt;function name="administrator" id="531" access="0"/&gt;&lt;function name="author" id="532" access="1"/&gt;&lt;function name="publisher" id="533" access="0"/&gt;&lt;function name="editor" id="539" access="0"/&gt;&lt;/admin_functions&gt;&lt;/permissions&gt;&lt;/root&gt; 10-04 14:30:08.696: debug/login result is(439): </loginresult></loginresponse></soap:body></soap:envelope> 

the child node coming user_id="testpub2" have convert xnode , value how covert xml node? , take value using saxparser. can take value directly?

the below code converts string xml document. once have document, can navigate nodes or can write file etc.

import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*;  public class util {      public static document stringtodom(string xmlsource)              throws saxexception, parserconfigurationexception, ioexception {         documentbuilderfactory factory = documentbuilderfactory.newinstance();         documentbuilder builder = factory.newdocumentbuilder();         return builder.parse(new inputsource(new stringreader(xmlsource)));     } } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -