Not always-- sometimes it is very important. You should be abnle to call
normalize to eliminate adjacent nodes. Also, some parsers require validation
mode to know whether or not whitespace is ignorable. As another solution you
can turn off indentation for the output and the problem will go away. If it
is a for loop that is giving a problem just check the nodeType.
HTH,
--
Jeff Rafter
Defined Systems
http://www.defined.net
XML Development and Developer Web Hosting
> Shouldn't whitespaces ignored by XML parsers, should they?
As far as I know, whitespace are ignored, if you use the
following code:
type
doc: IDomDocument;
(doc as IDomParseOptions).preserveWhiteSpace:=false;
(doc as IdomPersist).load('filename');
At least this works with libxmldom.pas and with msxml.
I am not shure, it it works with TXMLDocument, too.
If it doesn't, you could still right a procedure that removes
all whitespace nodes from the document, after you have parsed
it.
Regards:
Uwe
Which DOM Vendor are you using? Is poPreserveWhitespace false on the
TXMLDocument component? MSXML and OpenXML both support ignoring the
formatting whitespace #text nodes. The Xerces parser included with Delphi 7
or Kylix 3 doesn't support ignoring whitespace by default. If that is what
you are using then you can enable it by setting a property on the global
XercesDOM variable in the xercesxmldom.pas unit like this:
uses
xercesxmldom;
initialization
XercesDOM.EnablePreserveWhitespace(True);
With that set, the poPreserveWhitespace option on TXMLDocument will be
respected (if False). Be aware this is a post-parse operation and will have
performance implications for larger documents. There is basically a
recursive routine that removes the formatting nodes after the fact. Xerces
does not support ignoring formatting whitespace like MSXML does.
Mark
MSXML
> Is poPreserveWhitespace false on the
> TXMLDocument component?
Was not! With ParseOptions = [poPreserveWhitespace] it works fine!
thx
Rolf