Welcome to MSDN Blogs Sign in | Join | Help

Resources for geekSpeak: Inside LINQ to XML with Paul Sheriff

Here are the resources mentioned on our show with Paul Sheriff. You can watch the recording here.

Good reference information for LINQ to SQL

Unanswered questions

Does XElement.Load chunk the loading of the XML document if it’s huge, and how is that chunking affected by the use of LINQ aggregates (group, sum, etc)?

It implements an XML Text Reader under the hood so it should take care of loading the file in chunks as needed. This means that aggregates will work fine on large files, although it might take awhile!<g>

Can a LINQ to XML query filter based on something in a CDATA section, either partial string matching, or if the CDATA is XML, can that be queried as well? If an XPATH expression can query down into CDATA, can LINQ to XML do it as well?

I cannot find any way to reference CDATA from within LINQ because CDATA is actually a comment in XML.

Published Thursday, April 24, 2008 1:04 PM by glengordon
Filed under:

Comments

# Microsoft news and tips &raquo; Resources for geekSpeak: Inside LINQ to XML with Paul Sheriff

# re: Resources for geekSpeak: Inside LINQ to XML with Paul Sheriff

Regarding the second "unanswered question"...

---

Q: "Can a LINQ to XML query filter based on something in a CDATA section, either partial string matching, [...]"

A: Do you mean like the following?

from cdata in xdoc.DescendantNodes().OfType<XCData>() where cdata.Value.Contains("test") select cdata

---

Q: "[...] or if the CDATA is XML, can that be queried as well?"

A:

from xmlInCData in (from cdata in xdoc.DescendantNodes().OfType<XCData>() where cdata.Value.StartsWith("<") select XElement.Parse(cdata.Value)) select xmlInCData.Element("child")

For these queries the xdoc can look like this...

<root>

 <child1>with some text</child1>

 <!--comment is this-->

 <![CDATA[This is a CDATA section and this is a test!!!]]>

 <child2>more text<![CDATA[and now test test again...]]></child2>

 <![CDATA[<root><child/></root>]]>

 <the-end />

</root>

Sunday, April 27, 2008 8:43 PM by TTT
Anonymous comments are disabled
 
Page view tracker