Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / May 2008

Tip: Looking for answers? Try searching our database.

XLINQ to Query and Validate Parts?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
coconet - 28 May 2008 21:16 GMT
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>
Martin Honnen - 29 May 2008 12:38 GMT
> 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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.