Many many mmmmmmany thanks, Oleg.
"Oleg Tkachenko [MVP]" wrote:
> Carlitos wrote:
>
> > A class in Xerces J-API (Java) called TextImpl contains a property that
> > returns whether the text is ignorable whitespace
> > (
http://xml.apache.org/xerces-j/apiDocs/org/apache/xerces/dom/TextImpl.html#isIgnorableWhitespace()). ;
> >
> > I guess when they refer to "ignorable whitespace" in Java we may interpret
> > that as an "insignificant whitespace" in .NET. Am I correct to say that?
> >
> > So, I need to manually convert some Java code to C#, and the following
> > excerpt shows the converted code, except for the line marked with
> > "//<--****". I have spent a lot of time trying to find out how that
> > if-statement could be converted to C# with no success, mostly because I am a
> > beginner in XML.
> >
> > The excerpt of code is this:
> >
> > XmlNodeList children = node.ChildNodes;
> > string svalue;
> > if ( children != null )
> > {
> > //we want to delete ignorable whitespace from
> > //the dom tree
> > for ( int z = 0; z < children.Count; z++ )
> > {
> > if ( children.Item(z) is XmlText) // instanceof TextImpl )
> > {
> > svalue = children.Item(z).Value.Trim();
> >
> > if ( (children.Item(z)).isIgnorableWhitespace() ) // <--****
> > {
> > node.RemoveChild( children.Item(z) );
> > z--;
> > }
> > }
> > }
> > }
> >
> > Three questions:
> > 1. Can we say that XmlText is the counterpart of Java Xerces' TextImpl
> > (reference:
> >
http://xml.apache.org/xerces-j/apiDocs/org/apache/xerces/dom/TextImpl.html) ?
>
> Yes, that's correct.
>
> > 2. Is it correct and safe to say that the term "insignificant whitespace"
> > referred in MSDN Library is the same as saying "ignorable whitespace" in Java?
>
> Yes, it's safe.
>
> > 3. How would the code line marked with "//<--****" in above's excerpt be
> > coded in C#?
>
> I believe it would be
> if ( children.Item(z)).NodeType == XmlNodeType.Whitespace )
>
> --
> Oleg Tkachenko [XML MVP, MCP]
>
http://blog.tkachenko.com