nbsp; return STRXML;
}
//format a node to string
public static String toString(Node node, Document doc)
{
String STRXML = null;
try
{
OutputFormat format = new OutputFormat(doc); //Serialize DOM
format.setEncoding("GB2312");
StringWriter stringOut = new StringWriter(); //Writer will be a String
XMLSerializer serial = new XMLSerializer(stringOut, format);
serial.asDOMSerializer(); // As a DOM Serializer
serial.serialize((Element) node);
STRXML = stringOut.toString(); //Spit out DOM as a String
}
catch (Exception e)
{
e.printStackTrace();
}
return STRXML;
}
public static void main(String[] args) throws Exception
{
String pathRoot = "NeTrees.xml";
Document doc,doc1;
try
{
doc = xmlUtil.getDocument(pathRoot);
doc1 = xmlUtil.getDocument(pathRoot);
if(doc == doc1)
{
System.out.println("They are same objects!");
}
&nbs
}
//format a node to string
public static String toString(Node node, Document doc)
{
String STRXML = null;
try
{
OutputFormat format = new OutputFormat(doc); //Serialize DOM
format.setEncoding("GB2312");
StringWriter stringOut = new StringWriter(); //Writer will be a String
XMLSerializer serial = new XMLSerializer(stringOut, format);
serial.asDOMSerializer(); // As a DOM Serializer
serial.serialize((Element) node);
STRXML = stringOut.toString(); //Spit out DOM as a String
}
catch (Exception e)
{
e.printStackTrace();
}
return STRXML;
}
public static void main(String[] args) throws Exception
{
String pathRoot = "NeTrees.xml";
Document doc,doc1;
try
{
doc = xmlUtil.getDocument(pathRoot);
doc1 = xmlUtil.getDocument(pathRoot);
if(doc == doc1)
{
System.out.println("They are same objects!");
}
&nbs
| 对此文章发表了评论 |
