on 06-30-2006 8:17 AM
hello together,
we will receive xml messages over mailadapter. normally the communication partner sends the messages in a good format (no whitespaces between tags). but sometimes it is a bad format like this (caused by outlook preformatting maybe) :
<tag1>
...<tag1.1></tag1.1>
...<tag1.2></tag1.2>
</tag1>
the points '.' will be symbols for blanks or other whitespaces between end-tag of previous node(</tag1.1>) and start-tag(<tag1.2>) of current node in the message. and that is the problem (wrong working of java file).
the difference to a good file:
<tag1><tag1.1></tag1.1><tag1.2></tag1.2></tag1>
the internet browser will show it in xml formatted tags with '+' and '-' and if we have a look at the source code we will find a 'good' file.
so my question: how can i delete the whitespaces between closing and opening tags in java? do anybody know a standard java function to handle this problem?
thanks a lot
alex
did you try ...
http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html#replace(char,%20char)
replace(" ","");
maybe it works ... also try a trim() too ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi shabarish,
this idea is ok.
but to use the replace or trim function i have to convert the document to string.
<i>(the document will be parsed with 'Document doc = docBuilder.parse(in);'.)</i>
now, your advice: <i>String test = doc.toString().replace(" ","")</i>
but how can i make the string to xml file again to use some node functions on it?
do you know anything to that issue?
thanks a lot
alex
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.