Answered by:
Case sensitivity in XLINQ

Question
-
I have the following XML
Dim xmlTreeThree = <Products> <Product id=<%= ProductID %>> <ProductName>Widget</ProductName> <ProductPrice>49.99</ProductPrice> </Product> </Products> xmlTreeThree.Save("products3.xml") xmlDoc = XDocument.Load("products3.xml")
The following statement works as expected
Item = From p In xmlDoc...<Product> Where p.@id = ProductID Select p
Item = From p In xmlDoc...<Product> Where p.@ID = ProductID Select p
So my question is, is there a way to bypass the case sensitivity mentioned above and make either work or must I insure proper casing?
Thanks,
Kevin
KSGFriday, March 27, 2009 4:40 PM
Answers
-
XML is case-sensitive and so is LINQ to XML. That might not fit into VB which usually is case-insensitive but those constructs like ...<Product> or @id are simply translated into method calls like Descendants("Product") or Attribute("id").Value and there you are back to XML's case-sensitivity. Thus even with VB with LINQ to XML you have to pay attention to the case of element or attribute names.
MVP XML- Marked as answer by Pawel KadluczkaModerator Monday, March 30, 2009 4:10 PM
Friday, March 27, 2009 6:08 PM
All replies
-
XML is case-sensitive and so is LINQ to XML. That might not fit into VB which usually is case-insensitive but those constructs like ...<Product> or @id are simply translated into method calls like Descendants("Product") or Attribute("id").Value and there you are back to XML's case-sensitivity. Thus even with VB with LINQ to XML you have to pay attention to the case of element or attribute names.
MVP XML- Marked as answer by Pawel KadluczkaModerator Monday, March 30, 2009 4:10 PM
Friday, March 27, 2009 6:08 PM -
XML is totally case-sensitive, including element names, attribute names, entity names (general/parameterized), attribute values, text contents, etc. Please refer to http://xml.silmaril.ie/authors/case/ for more details.
Thus, you cannot bypass case sensitivity and must ensure proper casing in your code.Saturday, March 28, 2009 6:05 AM -
Thanks for the clarification
KSGMonday, March 30, 2009 5:01 PM -
Thanks for the clarification
KSGMonday, March 30, 2009 5:02 PM