Menu

White space in element text

2001-09-08
2001-09-11
  • Cornelius Theron

    I have a problem comparing the following XML:

    <Dog Name="Zombi"><Features Color="Black"/></Dog>

    and

    <Dog Name="Zombi">
      <Features Color="Black"/>
    </Dog>

    The reason is that the XMLUnit.compare(Element control, Element test) method uses Element.getText() that returns "" in the first example and "\n\r  " in the second example for the <Dog> element.

    I changed the code to ignore leading and trailing \n,\r,and \u0020. Are there better solutions?

     
    • Jeff Martin

      Jeff Martin - 2001-09-09

      You should be able to call XMLUnit.setIgnoreWhitespace(true) which should make the two equivilent.

      If it doesn't then this is a bug and I'll look into to it.

       
      • Cornelius Theron

        The source I downloaded does not have anything like setIgnoreWhitespace(). The timestamp of XMLUnit.java is 4/1/01 11:57, do you have newer source?

         
    • Cornelius Theron

      Sory, I see it is in the CVS. I'll try it.

       

Log in to post a comment.

MongoDB Logo MongoDB