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 / October 2006

Tip: Looking for answers? Try searching our database.

XML and Line Breaks/Whitespace

Thread view: 
JC - 16 Oct 2006 17:19 GMT
I am parsing an XML file that has line breaks.  When I use the method
"getChildNodes" on a Node (which returns a NodeList of the children of
that node), I am receiving the line breaks and spaces as children.

What is the best way to remove/ignore these line breaks?  Can I do it
up front, or do I have to do it after I get the children nodes?
Oliver Wong - 16 Oct 2006 17:33 GMT
>I am parsing an XML file that has line breaks.  When I use the method
> "getChildNodes" on a Node (which returns a NodeList of the children of
> that node), I am receiving the line breaks and spaces as children.
>
> What is the best way to remove/ignore these line breaks?  Can I do it
> up front, or do I have to do it after I get the children nodes?

See http://www.oracle.com/technology/pub/articles/wang-whitespace.html

   - Oliver
Tom Forsmo - 17 Oct 2006 12:49 GMT
> I am parsing an XML file that has line breaks.  When I use the method
> "getChildNodes" on a Node (which returns a NodeList of the children of
> that node), I am receiving the line breaks and spaces as children.
>
> What is the best way to remove/ignore these line breaks?  Can I do it
> up front, or do I have to do it after I get the children nodes?

Are you saying the parser returns content with line breaks/spaces after
what would be the end element/attribute or is the problem just generally
that the content of an element or attribute has line breaks?

Its not supposed be any line breaks after an element or attribute after
parsing, if there is there is a fault in the parser. But if there are in
the content  its a matter independent of xml and can be fixed with any
standard string manipulation tools. Have a look at the StringUtil in
Apaches Commons or perhaps java regexp.

tom


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.