Standalone XML with parser from IBM
Hello!(All XML-classes used in this can be found at)
http://www-3.ibm.com/software/webservers/appserv/doc/v35/ae/apidocs/index.html
I receive a XML-structure thats look like:
<?xml version="1.0" standalone="yes"?>
<product>
<header>
<message_id_send>511114351</message_id_send>
<message_id_get>511114351</message_id_get>
<error_message></error_message>...
I try to read it with:
StringReader sr = new StringReader(XMLString);
Parser parser = new Parser("test");
Document document = parser.readStream(sr);
Then i try to get a element:
getFieldValue("error_number", _document);
Ande the method getFieldValue looks like:
protected String getFieldValue(String tagname, Document document)
{
String value = null;
try
{
NodeList nodeList = document.getElementsByTagName(tagname);
Element node = (Element) nodeList.item(0);
try
{
value = node.getFirstChild().getNodeValue();
}
catch(NullPointerException npe)
{
value = null;
}
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
return value;
}
But I always get this message at line with Element node = (Element) nodeList.item(0);:
file:/D:/Inetpub/fap_se/Java/test: 1, 108: Element, "message_id_send" is not dec
lared in the DTD
java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Vector.java:427)
at com.ibm.xml.parser.TXNodeList$VectorNodeList.item(TXNodeList.java)
at com.fap.xml.DataStorer.getFieldValue(DataStorer.java:94)
at com.fap.xml.If.IfDataStorer.isDocumentOk(IfDataStorer.java:767)
at com.fap.xml.If.IfDataStorer.store(IfDataStorer.java:80)
at com.fap.xml.XMLManager.transmit(XMLManager.java:517)
at com.fap.xml.XMLManager.run(XMLManager.java:152)
at java.lang.Thread.run(Thread.java:536)
So if some one know how to tell the parser to parse without DTD as the xml-head says - standalone, please let me know.
Best Regards.
PS I can not use an other Parser since this is in a big project with a lot of developers.
