Skip to content

when IgnoreWhitespace, XmlDiffDocument doesn't ignore it #5

@bill2004158

Description

@bill2004158

Sample xml:

<a>
  <b>2</b>
</a>

between the element <a> & <b>, there is Text element which content is "\n ".
as IgnoreWhitespace, which should be ignored.

however, it will be trimmed, and add as a child node.
https://github.com/lovettchris/xmldiff/blob/master/src/XmlDiff/XmlDiffDocument.cs#L173

case XmlNodeType.Text:
{
   string textValue = ( _XmlDiff.IgnoreWhitespace ) ? XmlDiff.NormalizeText( reader.Value ) : reader.Value;
   XmlDiffCharData charDataNode = new XmlDiffCharData( ++childPosition, textValue, XmlDiffNodeType.Text );
   charDataNode.ComputeHashValue( _xmlHash );
   InsertChild( parent, charDataNode );
   break;
}

if compare with this xml (IgnoreWhitespace):

<a><b>2</b></a>

because they have different child nodes,
they will have different HashValue,
as a result, xmlDiff.Compare() will return false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions