将String转换为org.w3c.dom文档

时间:2015-06-03 20:08:49

标签: java xml

我通过javascript从servlet接收此字符串:

 %3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22no%22%3F%3E%3Crunningparameters%3E++%0A%09%3Caccesskey%3Eawd%3C%2Faccesskey%3E%0A%09%3Csecretkey%3ErL8cuC6GzH%2F8zHycg45sM47MqQMVVPmgZjdgDIJS%3C%2Fsecretkey%3E%0A%09%3Ckeyfile%3E%2FTdcGooglePrototype%2Fresources%2Ffrank_arianit_keypair.pem%3C%2Fkeyfile%3E%0A%09%3Creadybucketname%3Efa-initialbucket%3C%2Freadybucketname%3E%0A%09%3Cdonebucketname%3Efa-completedbucket%3C%2Fdonebucketname%3E%0A%09%3Cmanagertodownloader%3Ehttps%3A%2F%2Fsqs.eu-central-1.amazonaws.com%2F210890795349%2FFA_M2D%0A%09%3C%2Fmanagertodownloader%3E%0A%09%3Capplicationtomanager%3Ehttps%3A%2F%2Fsqs.eu-central-1.amazonaws.com%2F210890795349%2FFA_A2M%0A%09%3C%2Fapplicationtomanager%3E%0A%09%3Cpolicyconfig%3Ehttps%3A%2F%2Fsqs.eu-central-1.amazonaws.com%2F210890795349%2FFA_Policy%0A%09%3C%2Fpolicyconfig%3E%0A%09%3Cqueuelength%3E100%3C%2Fqueuelength%3E%0A%09%3Cnumberofdownloader%3E100%3C%2Fnumberofdownloader%3E%0A%09%3Cdownloadspeed%3E10%3C%2Fdownloadspeed%3E%0A%09%3Cpagerankthreshold%3E0.001%3C%2Fpagerankthreshold%3E%0A%09%3Ctotalpages%3E10000%3C%2Ftotalpages%3E%0A%09%3Cpagerankmaxloop%3E10%3C%2Fpagerankmaxloop%3E%0A%09%3Ccountryfilters%3E%0A%09%09%3Curlcountry%3Ecom%3C%2Furlcountry%3E%0A%09%3C%2Fcountryfilters%3E%0A%09%3Cfiletypefilters%3E++++++%0A%09%09%3Curlfiletype%3Epdf%3C%2Furlfiletype%3E%0A%09%09%3Curlfiletype%3Ehtml%3C%2Furlfiletype%3E++%0A%09%09%3Curlfiletype%3Ehtm%3C%2Furlfiletype%3E%0A%09%3C%2Ffiletypefilters%3E%0A%09%3Cseedurls%3E%0A%09%09%09%3Curl%3Ehttp%3A%2F%2Fwww.cnn.com%2F%3C%2Furl%3E+%09%0A%09%3C%2Fseedurls%3E%0A%3C%2Frunningparameters%3E

它在xml中,但有点看起来搞砸了。有没有办法将其转换为dom文档?

我试过了:

Document d;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
d = parser.parse(xmlstring);

但它不起作用,因为我知道字符串格式看起来很疯狂。

0 个答案:

没有答案