Xerces: Ignoring blank characters in XML Source

Posted on 2003-03-21
Medium Priority
Last Modified: 2012-05-04
I want to ignore white spaces while parsing an XML Source.


The Node value for TEXTNODE for NODE12, is the following ASCII chars 10-32-32-32-32-32-32
(essentailly blank charanters). How can I configure my parser to ignore these white spaces and return an empty string for the node value, or better still, return a NULL TEXTNODE.

I dont know it this is relevant, but I also require


to be an illegal XML Fragment, even if I am ignoring blank spaces.

Further, if I try fetching the text of <NODE></NODE>, there is no node text. I want <NODE></NODE> to have a node text which is an empty string. At the same time <NODE/> should have a NULL node text.

The following are the details:

OS:                   HP 11
Parser:               Xerces DOM Parser v2.2.0
Compilation:          Xerces compiled on 64 bit, with aCC
Other Compiler Opts:  -AA -mt

I am a novice at C++ - Xerces programming and am using Xerces to manipulate XML Sources. Any help will be greatly appreciated.

Thanks and Regards,
Question by:pballs
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 27

Expert Comment

ID: 8180236
Whitespace is normally preserved since the default for xml:space is preserve.

There is a SAX method isIgnorableWhiteSpace() which you can apply to any text found to determine whether the text is white space.

Lastly the fragment you have given IS illegal irrespective of what happens to the whitespace.


Author Comment

ID: 8180260
In that case, I will implement a method called/similar to isIgnorableWhiteSpace() to check. Would that be the only/most-elegant solution?

Thanks and Regards..
LVL 27

Accepted Solution

BigRat earned 200 total points
ID: 8180332
I think so. Xerces does not seem to have a writeable property called preserveWhiteSpace = Yes/No like the MS parser, and modifing the XML to introduce a xml:space attribute somewhere is messy, so that is probably the ONLY solution!

Author Comment

ID: 8180341
Thanks HTH. That's great help.

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question