<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> is inserted when modify xml with java -
i want modify html(xml) add 1 node. after that, 1 element added well. , line make file corrupted. weird. can 1 have look?
here code.
private void linkprepare(string buildnum) { // todo auto-generated method stub documentbuilderfactory domfac = documentbuilderfactory.newinstance(); documentbuilder dombuilder; try { dombuilder = domfac.newdocumentbuilder(); inputstream = new fileinputstream( "file/test"); document doc = dombuilder.parse(is); nodelist nodes = doc.getelementsbytagname("div"); node firstnode = nodes.item(0); element newnode = doc.createelement("ul"); firstnode.appendchild(newnode); transformerfactory transformerfactory = transformerfactory .newinstance(); transformer transformer = transformerfactory.newtransformer(); domsource source = new domsource(doc); streamresult result = new streamresult(new file( "file/test")); transformer.transform(source, result); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } }
and here html file,
<html> <head> <title>ota</title> </head> <body> <div> <ul></ul> </div> </body> </html>
Comments
Post a Comment