lundi 29 juin 2015

Linq to XML - Read/Parse only first lines of the file

Is it possible to parse only part of an xml-file using LINQ to XML?

Let's take the following file as example:

<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<FileWithData>
    <Header>
        <Type>File</Type>
        <Content>Data</Content>
    </Header>
    <TonsOfData>
        .......
    </TonsOfData>
</FileWithData>

I would like to read the Header information from several of such files, however loading them with XElement.Load(pathXmlFile) and navigate to the Header-node takes quite some time. Is it possible to somehow parse only a subtree from my xml structure to speed things up?

Aucun commentaire:

Enregistrer un commentaire