on 04-23-2009 1:34 PM
Hi all,
I have pasted an xml file in Mimes->Components and my file name is Doc_List.xml after that i have done some manipulations using that file like this
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("//Doc_List.xml");
String name = "description";
NodeList nlst = doc.getElementsByTagName("name");
Node node= nlst.item(0).getFirstChild();
//node.setNodeValue(name);
String a = node.getNodeValue();
wdComponentAPI.getMessageManager().reportSuccess(a);
the exception iam getting is java.io.FileNotFoundException: /Doc_List.xml (No such file or directory)
Hi,
Place your xml file under the path src/mimes/Components/<your component name>. Then use the following code to read it:
String xmlUrl = WDURLGenerator.getResourcePath
(wdComponentAPI.getComponent().getDeployableObjectPart(),
"FileName.xml"
);
if(xmlUrl != null){
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse(new File(xmlUrl));
doc.getDocumentElement ().normalize ();
// do further processing...
}
Regards,
Satyajit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
put the file in src -->Mimes->Components-> <your component>
and try
Document doc = db.parse("Doc_List.xml");
Regards
Matteo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahesh,
Bind the name of xml file with a context and use that context value in your code.
regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.