using XML

Posts   
 
    
WMS
User
Posts: 11
Joined: 26-May-2004
# Posted on: 26-May-2004 09:18:27   

Hi, Otis

Can you give an example of how to save a collectionEntity to xml file in hard disk. I look at the documentation, but still blur about the usage of WriteXml.

What is the meaning of the parameters ByRef entityCollectionXml As String _ ByVal rootNodeName As String, _ ByVal parentDocument As XmlDocument, _ ByRef entityCollectionNode As XmlNode _

Thanks a million. simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 26-May-2004 10:23:38   

WriteXml has various overloads.

public void WriteXml(out string entityCollectionXml) is the most simple one. It will return the entity collection in XML in the form of a string. call it like this:

string xml = string.Empty; customers.WriteXml(out xml); // now 'xml' contains the collection in XML. You can now save xml with a streamwriter.

public void WriteXml(XmlDocument parentDocument, out XmlNode entityCollectionNode) is more complex, you pass in an XmlDocument object in which you want to have the collection XML. It returns the node which contains the complete tree of XmlNodes with the collection data. This node is created with the passed in XmlDocument and thus can be added to it without hassle.

public void WriteXml(string rootNodeName, out string entityCollectionXml) This is also a simple one. It is almost the same as public void WriteXml(out string entityCollectionXml) but this version lets you specify the root node name, for example "MyCollection", so the rootnode will be <MyCollection>.

public virtual void WriteXml(string rootNodeName, XmlDocument parentDocument, out XmlNode entityCollectionNode) You might guess what this one does simple_smile It's the same as public void WriteXml(XmlDocument parentDocument, out XmlNode entityCollectionNode) but now lets you specify the name of the root node.

I hope this clears something up simple_smile

Frans Bouma | Lead developer LLBLGen Pro
WMS
User
Posts: 11
Joined: 26-May-2004
# Posted on: 26-May-2004 13:10:37   

Thank you very much for the fast reply. I got it.
so that is the reason the string is passed by reference, right? You try to avoild using functions which just returns the string for reason of the standard interface?

hope you can add some example in the reference manual in future. That will be much better.