How embeded xml file ?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-size:medium <span lang="EN
<p dir="LTR Hi ,
<p dir="LTR I am creating my first add-in and i have xml file to store any word added by user

<p dir="LTR but when i setup it and run it on internet explorer the error message appear for me

<p dir="LTR i put it in debug file
<p dir="LTR  
<p dir="LTR  i need to know how embedded xml file in my add-in to premit the user add and delete new word ?
<p dir="LTR plz help me :)
<pre class="prettyprint XmlTextReader reader = new XmlTextReader("Grammar.xml");
XmlNodeType type;

while (reader.Read())
{
type = reader.NodeType;

if (type == XmlNodeType.Element)
{

if (reader.Name == "item")
{
reader.Read();

listBox1.Items.Add(reader.Value);
}
}
}

reader.Close();
}

private void button4_Click(object sender, EventArgs e)
{
button5.Enabled = false; // disable load xml file
button4.Enabled = true; // enable save xml file

try
{
XmlTextWriter writer = new XmlTextWriter("Grammar.xml", Encoding.UTF8);
writer.Formatting = Formatting.Indented;

writer.WriteStartDocument();
writer.WriteStartElement("grammar");
writer.WriteAttributeString("xmlns", "http://www.w3.org/2001/06/grammar");
writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString("xml:lang", "en-US");
writer.WriteAttributeString("version", "1.0");
writer.WriteAttributeString("root", "command1");
writer.WriteStartElement("rule ");
writer.WriteAttributeString("id", "command1");
writer.WriteAttributeString("scope", "public");
writer.WriteStartElement("one-of");


foreach (string item in listBox1.Items)
{
writer.WriteStartElement("item");
writer.WriteString(item);
writer.WriteEndElement(); //WORD
}

writer.WriteEndElement(); //COMMAND
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();// End Document

writer.Close();
MessageBox.Show("THE NEW WORDS ADD TO THE XML FILE !!", "Message");
}[/code]
<br/>
<p dir="LTR  
<p dir="LTR  
<p dir="LTR Thank u


View the full article
 
Back
Top