I've the below code
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace proj_TreeView_1
{
public partial class FrmTreeView : Form
{
public FrmTreeView()
{
InitializeComponent();
}
private void FrmTreeView_Load(object sender, EventArgs e)
{
}
private void btnTransferToXml_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
XmlNode node = doc.CreateNode(XmlNodeType.Element,"root",null);
foreach (TreeNode t in trViewContinent.Nodes)
{
node.AppendChild(getXmlNode(t, doc));
}
doc.AppendChild(node);
doc.Save("C:\\Users\\stag0215\\Desktop\\Continets.xml");
}
private XmlNode getXmlNode(TreeNode tnode,XmlDocument doc)
{
XmlNode node = doc.CreateNode(XmlNodeType.Element, tnode.Text,null);
foreach (TreeNode t in tnode.Nodes)
{
node.AppendChild(getXmlNode(t,doc));
}
return node;
}
}
}
and i'm getting the following error
XmlNode node = doc.CreateNode(XmlNodeType.Element, tnode.Text,null); <---- The ' ' character, hexadecimal value 0x20, cannot be included in a name.
thanks for your help