I have an XML document that I am parsing with JAXP.
The XML document has a segment:
<heading class="heading 1" ... ... ...
If i parse this attribute and put the string value into a variable, say
named value. If i then System.out.println(value) i will see
heading 1
This is fine, but if i were to do the following:
if (value.equals("heading 1")) {
code
}
The code will not execute. Why is this, and how can i remedy the
problem?
Daniel Dyer - 05 Dec 2005 14:39 GMT
> I have an XML document that I am parsing with JAXP.
> The XML document has a segment:
[quoted text clipped - 14 lines]
> The code will not execute. Why is this, and how can i remedy the
> problem?
It's a different space character. You can use the \u00A0 escape sequence
to specify the non-breaking space in Java (or change your XML so that it
uses a regular space).
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk
Will - 05 Dec 2005 14:55 GMT
I am working with XML documents created by an external piece of
software so unfortunately cannot change the XML.
Is there a way i can "decode" the string so that I can compare parsed
strings with strings i code. (Ie value.equals("heading 1"))
David Wahler - 05 Dec 2005 18:34 GMT
> I am working with XML documents created by an external piece of
> software so unfortunately cannot change the XML.
>
> Is there a way i can "decode" the string so that I can compare parsed
> strings with strings i code. (Ie value.equals("heading 1"))
Did you read the comment you just replied to?
value.equals("heading\u00A01")
-- David