Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 368981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:52:33+00:00 2026-05-12T13:52:33+00:00

I have frequent need to test that XML files are correct and need a

  • 0

I have frequent need to test that XML files are correct and need a way of testing that 2 XML strings (or documents) are identical, such as:

XMLAssert.assertEquals(String xmlExpected, String xmlActual);

In addition it would be useful to show where the xml documents differed.

This should be restricted to documents with standalone=”yes” (i.e. the DTD or schema – if any – is not significant). This means that there are no default values, and attribute types are irrelevant. Adjacent text PCDATA nodes should be normalised (concatenated).

Note that this cannot be done simply by lexical comparison

Assert.assertEquals(xmlExpected, xmlActual);

as there are indefinitely many ways of rendering the same XML infoset. The comparison should take account of namespaces on elements and attributes (but not attribute values – which are not part of the spec).

One way to do this might involve canonicalising both documents. Alternatively an XMLDiff could be used.

I could not find anything so wrote my own a few years ago.

[I also have a particular need to compare floating point values though this must be a hack since the data type of CDATA or PCDATA can only be guessed and is out of immediate scope for the question.]

NOTE: There will probably need to be a specific solution for each language. I am particularly interested in Java and C#

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:52:33+00:00Added an answer on May 12, 2026 at 1:52 pm

    For Java, you should checkout XMLUnit. And I’ve just noticed that it comes with a .NET version too! Here’s a sample of the Java version:

    String myControlXML = "<msg><uuid>0x00435A8C</uuid></msg>";
    String myTestXML = "<msg><localId>2376</localId></msg>";
    assertXMLNotEqual(myControlXML, myTestXML);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have frequent updates to a user table that simply sets the last seen
I have a mid-size collection of records --about 20 million -- that I need
Ok, so I need to create a command that lists the 100 most frequent
I have a complex map, which doesn't need locking for the frequent gets and
I have a web page that I need to check the server for an
I have a small python script that prints the 10 most frequent words of
I have a normalized database and need to produce web based reports frequently that
I have sqlite database and need to find the most frequent words in it.
Duplicate: Do web sites really need to cater for browsers that don’t have Javascript
I have noticed that applications like GPS Status get a fix pretty quickly. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.