Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

XLINQ to Query and Validate Parts?

Question posted by: coconet (Guest) on June 27th, 2008 07:20 PM
I have a document that looks like the below. In the .NET 2.0 days, I
might use an XmlDomDocument to read the whole thing to see if it is a
basically good XML document. Then I might step through it with a
reader of some kind.

The entire XML document is now huge. Way too big to go into a DOM
document for parsing.

I was wondering if I could use LINQ for XML to query the "level_1"
parts to put each of them into something I can test, like a new
object.

Thanks.







<?xml version="1.0" encoding="UTF-8"?>
<Feed>
<level_1>
<url>http://www.aaaaaa.com</url>
<urlalt>http://www.aaaaa.net</urlalt>
<title>title from one</title>
<desc>description from one</desc>
<richdata>
<![CDATA[
this is rich data from one
]]>
</richdata>
<subdata>
<subdata_a>
<title>sub-a</title>
<info>sub-a information</info>
</subdata_a>
</subdata>
</level_1>
<level_1>
<url>http://www.bbbbb.com</url>
<urlalt>http://www.bbbbb.net</urlalt>
<title>title from two</title>
<desc>description from two</desc>
<richdata>
<![CDATA[
this is rich data from two
]]>
</richdata>
<subdata>
<subdata_a>
<title>sub-b</title>
<info>sub-b information</info>
</subdata_a>
</subdata>
</level_1>
</Feed>
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Martin Honnen's Avatar
Martin Honnen
Guest
n/a Posts
June 27th, 2008
07:20 PM
#2

Re: XLINQ to Query and Validate Parts?
coconet wrote:
Quote:
Originally Posted by
I was wondering if I could use LINQ for XML to query the "level_1"
parts to put each of them into something I can test, like a new
object.


If I understand you correctly then the document contains other elements
besides the "level_1" elements and you only want to store the level_1
stuff. In that case have a look at the approach described in
http://msdn.microsoft.com/en-us/library/bb387008.aspx, it shows how to
use the ReadFrom method to read an XML fragment from an XmlReader.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

 
Not the answer you were looking for? Post your question . . .
182,271 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors