LinQ to xml: Xml without start & end tags
I know that when using LinQ it is possible to have an element that is not attached to any root document, but is it possible to take that one step further and have xml data that has no root element; essentially a collection of XElements?
xml:
<XElement1>
<someData>data</someData>
</Xelement1>
<XElement2>
<someData>data</someData>
</Xelement2>
<XElement3>
<someData>data</someData>
</Xelement3>
开发者_开发问答...
...
Thnx.
You can use XmlTextReader or XmlValidatingReader to read xml fragments:
http://msdn.microsoft.com/en-us/library/cakk7ha0(v=VS.100).aspx
http://msdn.microsoft.com/en-us/library/k4yze3k7.aspx
<XElements>
//elements
</XElements>
Root is # necessary
If you're not interested in storing it in a file, then just use List. If you do need to store it in a file then the links about reading XML fragments mentioned above by mamoo are what you're looking for.
精彩评论