Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of attributes matter to XNode.DeepEquals #830

Open
jahav opened this issue Aug 14, 2018 — with docs.microsoft.com · 1 comment
Open

Order of attributes matter to XNode.DeepEquals #830

jahav opened this issue Aug 14, 2018 — with docs.microsoft.com · 1 comment
Labels
area-System.Xml dotnet-api/prod Pri2 Indicates issues/PRs that are medium priority untriaged New issue has not been triaged by the area owner

Comments

Copy link

jahav commented Aug 14, 2018

The description is misleading: "Two XElement nodes are equal if they have the same tag name, the same set of attributes with the same values" would suggest that order of attributes doesn't matter (since it is a set), but the order does matter.

E.g. following will result in false, i.e. noequivalent XMLs.
XElement xmlTree1 = new XElement("Root",
new XAttribute("Att1", 1),
new XAttribute("Att2", 2)
);
XElement xmlTree2 = new XElement("Root",
new XAttribute("Att2", 2),
new XAttribute("Att1", 1)
);
Console.WriteLine(XNode.DeepEquals(xmlTree1, xmlTree2));

I am not sure how exactly are the attributes compared, but perhaps "two equal length sequences of equal attributes" is closer to truth.

EDIT:
The reference source says that my description of attribute equality is basically accurate, attributes are compared from first to last on both sides and each one must have same name and value:
https://referencesource.microsoft.com/#System.Xml.Linq/System/Xml/Linq/XLinq.cs,d4ee71a752e8b485


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@LeonidVasilyev
Copy link

Relevant excerpt from Extensible Markup Language (XML) 1.0 (Fifth Edition):

[Definition: The Name-AttValue pairs are referred to as the attribute specifications of the element], [Definition: with the Name in each pair referred to as the attribute name ] and [Definition: the content of the AttValue (the text between the ' or " delimiters) as the attribute value.] Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.

@BillWagner BillWagner transferred this issue from dotnet/docs Nov 20, 2018
@dotnet-bot dotnet-bot added untriaged New issue has not been triaged by the area owner Source - Docs.ms and removed rerun-labels labels Nov 20, 2018
@PRMerger10 PRMerger10 added the Pri2 Indicates issues/PRs that are medium priority label Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Xml dotnet-api/prod Pri2 Indicates issues/PRs that are medium priority untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

6 participants