on 05-27-2008 5:44 PM
Hi Experts
Do you Know how can I write I DOM XML
the header of file I Mean
<?xml version="1.0" encoding="iso-8859-8"?>
Regards
Yossi
Thank you Ayyapparaj for yor answer
Best regards
Yossi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
say u have xml with following structure
<xml>
<Age>xyz</Age>
</xml>
to append age node, parse the xml string or file and try the following code
HERE DOM is used
Document xmlDoc = wdThis.ParseFile(xmlString);
Node root=xmlDoc.getDocumentElement();
Node AgeNode = xmlDoc.createElement("Age");
Node AgeTextNode = xmlDoc.createTextNode("25");
AgeNode.appendChild(AgeTextNode);
root.appendChild(AgeNode);
following code to parse the xml string
public org.w3c.dom.Document mParseFile( java.lang.String XmlString )
{
//@@begin mParseFile()
//pearse the xml string passed
IWDMessageManager mesg = wdComponentAPI.getMessageManager();
String l_method = "mParseFile";
//parsing xml string to xml document
ByteArrayInputStream l_xmlDataInputStream = new ByteArrayInputStream(p_XmlString.getBytes());
Document l_doc = null;
InputSource in = new InputSource((InputStream) l_xmlDataInputStream );
DocumentBuilderFactory l_dbf = DocumentBuilderFactory.newInstance();
l_dbf.setValidating(true);
l_dbf.setNamespaceAware(true);
DocumentBuilder l_db;
try {
l_db = l_dbf.newDocumentBuilder();
l_doc = l_db.parse(in);
}
catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (IOException e) {
}
//returns xml document
return l_doc;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.