Reputation: 1
Is it any XML .net library like simplexml in PHP? For example:
<root>
<obj>
<val>value1</val>
</obj>
<obj>
<val>value1</val>
</obj>
</root>
objects = .....Parse(xml);
Console.WriteLine(objects[0].val.ToString());
Upvotes: 0
Views: 1073
Reputation: 1041
Try creating an schema from your xml document and then generate a class from that schema. After that, you can use serialization to read/write xml documents.
More information here:
http://msdn.microsoft.com/en-us/library/x6c1kb0s%28VS.80%29.aspx
In the "Remarks" section you'll find "xsd to classes" where the XmlSerialization approach is mentioned.
Upvotes: 0
Reputation: 20246
Linq to XML is probably pretty close once you get used to the Linq syntax. Some good samples here. Then you can use Descendants
to get all of the elements below it, or Elements
to get a collection of immediate children, etc. The query syntax is quite nice for filtering out just the stuff you care about though. For example you can get to all of the elements of type obj
using:
var root = XElemenet.Parse( /* [xml string goes here] */ );
var objects = root.Descendants("obj");
foreach( var o in objects ){
Console.WriteLine( o.Value );
}
Upvotes: 0
Reputation: 137148
Well there's the XMLDocument
class>
Represents an XML document.
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document and enables the navigation and editing of this document.
Upvotes: 1