Working with pieces of XML.
Date: 08/24/06
(C Sharp) Keywords: xml
What is(are) the best class(es) to store pieces of xml for latter creation of XmlDataDocument out of them?
You know how you usually make Xml Schema-defined types into C# classes? Well, I want each one of those to be able to output its own piece of XML. This way I can build the class hierarchy corresponding to the schema hierarchy, and one line of code would output the complete xml of some specific schema type, or the whole XML page.
For example:
class Phone
{
public string id;
public string phone;
public Phone()
{}
public INSERT_SOME_CLASS_HERE getXml()
{
INSERT_SOME_CLASS_HERE myObject = new INSERT_SOME_CLASS_HERE();
// Building xml elements
return myObject;
}
}
Any example what class should I use? Manipulate with XmlElement? XmlNode? Or should I just use XmlDataDocuments, and keep merge them together somehow?
Thanks.
Source: http://community.livejournal.com/csharp/74707.html