Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Java & XML

Thread view: 
Will - 05 Dec 2005 14:35 GMT
I have an XML document that I am parsing with JAXP.
The XML document has a segment:

<heading class="heading&#160;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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.