Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know exactly what you're trying to accomplish but personally I would create a .NET class representing your class element with properties identifying the sub elements then use System.Xml.Serialization.XmlSerializer to write or read it from a file.</p> <p>Here is an example:</p> <pre><code>using System.Xml.Serialization; public class MyClasses : List&lt;MyClass&gt;{} public class MyClass{ public String Teacher{ get; set; } } void main(){ MyClasses classList = new MyClasses(); MyClass c = new MyClass(); c.Teacher = "James"; classList.Add(c); XmlSerializer serializer = new XmlSerializer(classList.GetType()); serializer.Serialize(/*Put your stream here*/); } </code></pre> <p>And, after leaving setting up your stream as an exercise to the reader, blamo, you're done outputing an XML representation of your object to some stream. The stream could be a file, string, whatever. Sorry for nasty C# (if its nasty) I use VB.NET everyday so the syntax and keywords may be a little off. </p> <p><strong>Update</strong><br> I added some code to show how to serialize a collection of the classes. If nodes aren't coming out named correctly there are attributes you can add to your class properties, just do a quick google for them.</p> <p><strong>Update again</strong><br> Sorry, its hard to explain when we're using the same word to mean two different things. Lets say you're trying to represent a bucket of bricks. You would write a C# class called <code>Brick</code> and a C# class called <code>Bucket</code> that inherited from <code>List&lt;Brick&gt;</code> your <code>Brick</code> would have a property called <code>Color</code>. You would then make all your bricks with different colors and fill the bucket with your bricks. Then you would pass your bucket to the serializer and it would give you something like: </p> <pre><code>&lt;Bucket&gt; &lt;Brick&gt; &lt;Color&gt; blue &lt;/Color&gt; &lt;/Brick&gt; &lt;/Bucket&gt; </code></pre> <p>The serializer builds the XML for you from the definitions of your classes so you don't have to worry about the details. You can read more about it <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx" rel="nofollow noreferrer">here</a> and <a href="http://msdn.microsoft.com/en-us/library/ms733901.aspx" rel="nofollow noreferrer">here</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload