J
John
I have been trying with no result, to force Xerces parsers to ignore
whitespace in my XML file. I have tried several of the NG suggested
setFeature() methods in DOMParser to no avail.
I have now started to use the newest version of Xerces and as a result
I stopped using DOMParser. The following fragment of my code shows how
I create the parser and parse my XML file, which still has <null>
#text fields for whitespace. How can I force Xerces to ignore them?
Thanks,
John
Java Code:
=======
public class XMLConvert {
private DocumentBuilderFactory builderFactory;
private DocumentBuilder docFactory;
private Document inDoc;
public static void main(String[] args)
{
XMLConvert xml = null;
try {
xml = new XMLConvert(new FileInputStream(new File(args[0])));
} catch(Exception e) {
e.printStackTrace();
}
}
public XMLConvert(InputStream is)
{
try {
builderFactory = DocumentBuilderFactory.newInstance();
docFactory = builderFactory.newDocumentBuilder();
inDoc = docFactory.parse(is);
} catch(Exception e) {
e.printStackTrace();
}
}
My simple XML file:
============
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Body>
Test
</Body>
</Envelope>
Output from Java (children of root element):
============================
Node Name: #text
Local Name: null
URI: null
Node Name: Body
Local Name: null
URI: null
Node Name: #text
Local Name: null
URI: null
whitespace in my XML file. I have tried several of the NG suggested
setFeature() methods in DOMParser to no avail.
I have now started to use the newest version of Xerces and as a result
I stopped using DOMParser. The following fragment of my code shows how
I create the parser and parse my XML file, which still has <null>
#text fields for whitespace. How can I force Xerces to ignore them?
Thanks,
John
Java Code:
=======
public class XMLConvert {
private DocumentBuilderFactory builderFactory;
private DocumentBuilder docFactory;
private Document inDoc;
public static void main(String[] args)
{
XMLConvert xml = null;
try {
xml = new XMLConvert(new FileInputStream(new File(args[0])));
} catch(Exception e) {
e.printStackTrace();
}
}
public XMLConvert(InputStream is)
{
try {
builderFactory = DocumentBuilderFactory.newInstance();
docFactory = builderFactory.newDocumentBuilder();
inDoc = docFactory.parse(is);
} catch(Exception e) {
e.printStackTrace();
}
}
My simple XML file:
============
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Body>
Test
</Body>
</Envelope>
Output from Java (children of root element):
============================
Node Name: #text
Local Name: null
URI: null
Node Name: Body
Local Name: null
URI: null
Node Name: #text
Local Name: null
URI: null