I am creating a xml file parsing a PB .srd file.
It is executing properly but the error is "MISSING ROOT
ELEMENT"
the code is:
sring[] dw_parts=null;
FileStream fs = File.Open("C:\\Documents and
Settings\\santhoshi\\Desktop\\dw_grid_qaddress.txt ",FileMod
e.Open,FileAccess.Read);
StreamReader sr = new StreamReader(fs);
StringReader rd = new StringReader(sr.ReadToEnd());
XmlTextWriter XMLWriter = new XmlTextWriter
("d:\\santhoshi\\projects\\current\\xmlwriter.xml" ,System.T
ext.Encoding.Unicode);
try
{
for(string line=rd.ReadLine();line!=null;line=rd.ReadLine
())
{
if(Regex.IsMatch(
line , "datawindow",RegexOptions.IgnoreCase))
{
dw_parts=Regex.Split(line,@"\s+|\s*=\s*|\s*\)
\s*|\s*\(\s*");
for(int i=0;i<dw_parts.Length;i++)
{
//XMLWriter.WriteString("<?xml
version="+'"'+"1.0"+'"'+"?>");
if
(Regex.IsMatch(dw_parts[i],"datawindow"))
{
XMLWriter.Formatting = Formatting.Indented;
XMLWriter.WriteStartDocument();
XMLWriter.WriteStartElement(dw_parts[i]);
//XMLWriter.WriteStartElement(dw_parts[i]);
}
else if(Regex.IsMatch(dw_parts[i],"units"))
{
XMLWriter.WriteStartElement("units",dw_parts[i++]);
}
}
XMLWriter.WriteEndElement();
//XMLWriter.WriteEndElement();
}
//
XmlDocument doc = new XmlDocument();
//
doc.Load
("d:\\santhoshi\\projects\\current\\xmlwriter.xml" );
}
}
catch(Exception X)
{
MessageBox.Show(X.Message);
}
}
For each match it should create a element or node with the
contents .
I am new to XML coding in C# can u please help me out