Hello all,
I am new to xml, and I thought I had a handle on things until I got this problem...I am getting an xml string from the body of an e-mail message, and then I am trying to extract elements out of it. Here is an example xml string:
<?xml version="1.0" encoding="UTF-8"?>
<filterRoot>
<filter action="MOVE" bool="AND" name="My Saved Filter" target="Deleted Items">
<condition attribute="TO" bool="AND" contains="CONTAINS">
<value>rizwan@gwu.edu</value>
<value>rizwan@seas.gwu.edu</value>
<value>rizwans@bigfoot.com</value>
<value>rizwan@rcn.com</value>
<value>rizwansattar@hotmail.com</value>
</condition>
</filter>
</filterRoot>
I am trying to extract the <filter> element out and store it into a Vector of Elements (called, not surprisingly, filters). However, I am getting a class cast exception:
java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImpl
It is being called from where I trying to extract the <filter> in this way:
filterRoot = doc.getDocumentElement(); // get topmost element
NodeList list = filterRoot.getChildNodes();
Vector newFilters = new Vector();
debug("There are "+list.getLength()+" filters in document");
for(int i=0; i<list.getLength(); i++) {
Node n = list.item(i);
debug("Node "+i+" getNodeValue() is "+n.getNodeValue());
Element temp = (Element)n;
newFilters.add(temp);
}
Perhaps my question is, how do I correctly get hold of the <filter> node so that I may cast it as an Element?
thanks,
Riz