-
xml parsing
i am getting null pointer exception when i tried to parse the xml using DOMParser i have checked the xsd file my xml is exactly the same. can anybody solve this problem its realy urgent and dont known where the error is. the code which iam using is
lsprSaxXmlParser=new DOMParser();
lsprSaxXmlParser.parse(new inputsource(new StringReader (StringBuffer.toString)));
i checked string buffer string reader and inputsource all of them has values in it
iam getting this error
java.lang.NullPointerException
at org.apache.xerces.framework.XMLParser.parse(XMLPar ser.java:1094)
-
Hi,
Am using dom parser to parse XML document. Am getting the following error while executing the parser class.
"Element type FirstName is not declared".
Can one tell me what causes this problem?
-
We need to see some code...!!
-
1 Attachment(s)
Xml parsing
Hi,
I have attached the Xml Schema definition and XML document for you.
Please go through and let me know where the issue exactly is...
Thanks in advance :)
-
Hello
Hello Java Community Forum,
This Bibhu Parasad new to such a big forum.I am happy with joining this site for communicating with all java professionals.
Regards
Bibhu
-
@gaurav
...see this code..hope it will help u..
//use document builder
File file = new File("mytext1.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.getDocumentElement().normalize();
System.out.println("Root element:-" + doc.getDocumentElement().getNodeName());
NodeList nodeLst = doc.getElementsByTagName("article");
f
System.out.println("--------Information of all Data-------");
log.debug("The Information of all the data is ");
for (int s = 0; s < nodeLst.getLength(); s++)
{
double sum=0.0;
Node fstNode = nodeLst.item(s);
if (fstNode.getNodeType() == Node.ELEMENT_NODE)
{
Element fstElmnt = (Element) fstNode;
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("title");
Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
NodeList fstNm = fstNmElmnt.getChildNodes();
System.out.println("Bill Value : " + ((Node) fstNm.item(0)).getNodeValue());
log.debug("Bill Value : " + ((Node) fstNm.item(0)).getNodeValue());
String str=((Node) fstNm.item(0)).getNodeValue();
sum=sum+Double.valueOf(str.trim()).doubleValue();
//System.out.println("sum=" +sum);