Thank you for the help now I can easily convert XML String to Document with StringReader. But now I have one more issue.
TestStr String = "<? Xml version = '1 .0 '?> <root> <El1> <title> Chapter1 </ title> </ EL1>
<El2> <title> Chapter2 </ title> </ El2> </ root>
And I want to convert this string into Document Dom to make subsequent treatments. (But without a file) wholesale before I did the treatment from a file with the following code:
Code:
public static Document ReadXmlFile (String XmlFiles)
(
Document document = null;
try
(
/ / Create a factory records
DocumentBuilderFactory factory = DocumentBuilderFactory. NewInstance ();
/ / Create a document builder
DocumentBuilder builder = factory. NewDocumentBuilder ();
/ / Read the contents of an XML file with DOM
File xml = new File (XmlFiles);
document = builder. parse (xml);
)
catch (ParserConfigurationException phr)
(
System. Out. System.out.println ("Error DOM parser configuration");
System. Out. System.out.println ("when calling to fabrique.newDocumentBuilder ();");
phr. printStackTrace ();
System. Exit (0);
)
catch (SAXException se)
(
System. Out. System.out.println ("Error parsing document");
System. Out. System.out.println ("when calling to construteur.parse (xml)");
System. Out. System.out.println ("DTDs are they have become in the directory?");
be. printStackTrace ();
System. Exit (0);
)
catch (IOException ioe)
(
System. Out. System.out.println ("Error input / output");
System. Out. System.out.println ("when calling to construteur.parse (xml)");
ioe. printStackTrace ();
System. Exit (0);
)
return document;
)
I will be waiting for your reply.
Bookmarks