【问题标题】:XMLUnit how to to ignore missing attributeXMLUnit 如何忽略缺失的属性
【发布时间】:2017-03-27 15:35:40
【问题描述】:

我很熟悉忽略属性值的差异,但是完全按名称忽略属性的正确方法是什么?如何使这两个文档评估为相似?

文档1:

<a attributeName="value"></a>

文档2:

<a></a>

【问题讨论】:

    标签: java xml xmlunit xmlunit-2


    【解决方案1】:

    这最终对我有用。 (如果有其他解决方案,请告诉我)

    DiffBuilder.compare(control.withTest(test)
                    .checkForSimilar()
                    .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName))
                    .ignoreWhitespace()
                    .withAttributeFilter(a -> !"attributeName".equals(a.getName()))
                    .build();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-19
      • 1970-01-01
      • 1970-01-01
      • 2018-11-26
      • 1970-01-01
      相关资源
      最近更新 更多