TheSwamp

Code Red => .NET => Topic started by: Andrey Bushman on November 23, 2012, 04:07:27 AM

Title: PackageContents.xml: problem with register of attribute/element names
Post by: Andrey Bushman on November 23, 2012, 04:07:27 AM
I use LINQ to XML for working with PackageContents.xml file, created by Autodesk company. Company has defined the structure of this XML file here (http://exchange.autodesk.com/autocad/enu/online-help/ACD/2012/ENU/pages/WS1a9193826455f5ff-4fe3487312ce8a8dba5-7feb.htm), but without XSD schema.

I have a problem: This company breaks his the rules... Often registers of elements and attributes is invalid. For example, instead of the "URL" attribute the "Url" attribute can be defined (different registers) - look the PackageContents.xml of FusionPlugin2013.bundle.

But register is important for XML (http://msdn.microsoft.com/ru-ru/library/ms256152.aspx):
Quote from: MSDN
Like element names, attribute names are case-sensitive and must start with a letter or underscore.

The "URL" is not equals "Url" - such attribute will not found. Can I solve this problem through LINQ to XML (or other), or I can't?

P.S. I have a hope, official documentation contains the invalid  element\attribute names.... It is "better", than a register independent variant...
Title: Re: PackageContents.xml: problem with register of attribute/element names
Post by: Andrey Bushman on November 23, 2012, 05:10:57 AM
If it is not mistakes in official documentation, and Autodesk really used case-independent XML parser, then I will must use such code in many places:
Code - C#: [Select]
  1. var attribute = x.Attributes().SingleOrDefault(xa => string.Equals(xa.Name.LocalName, "Url", StringComparison.InvariantCultureIgnoreCase));

Long ago I talk to myself at this forum. :(
Title: Re: PackageContents.xml: problem with register of attribute/element names
Post by: Kerry on November 23, 2012, 05:51:54 AM
< .. >

Long ago I talk to myself at this forum. :(

Andrey, at least you're talking to someone who is smart :)