jmahdi
March 12th, 2005, 06:12 PM
i'm trying to read from a string which reads data parsed from a web page :
foreach(Match m in Regex.Matches(getPage, prog.ToString()))
{
Group g = m.Groups[1];
string myString;
myString = g.ToString();
*
*
what i whant to do is place this string(data parsed from web page) in an XML format and this is what i have tried to do:
XmlTextWriter writer = new XmlTextWriter("data.xml", null);
//writer.WriteStartDocument();
//Use automatic indentation for readability. writer.Formatting = Formatting.Indented;
//Write the root element writer.WriteStartElement("Schedule");
//Start an element
writer.WriteStartElement("Title");
//add sub-elements
writer.WriteElementString("Programme", myString);
//writer.WriteElementString("Time", "09:00");
//End the item element
writer.WriteEndElement();
// end the root element
//writer.WriteFullEndElement();
//Write the XML to file and close the writer
writer.Flush();
writer.Close();
}
i've placed this code within the foreach loop!! i'm not sure if this is right any ways the out come is not what i wanted it to be,
[ it creates an xml file with only one element string and ignores all other ones].
<Schedule>
<Title>
<Programme>Up All Night</Programme>
</Title>
</Schedule>
please i need a tip from an expert...
thanks and regards
foreach(Match m in Regex.Matches(getPage, prog.ToString()))
{
Group g = m.Groups[1];
string myString;
myString = g.ToString();
*
*
what i whant to do is place this string(data parsed from web page) in an XML format and this is what i have tried to do:
XmlTextWriter writer = new XmlTextWriter("data.xml", null);
//writer.WriteStartDocument();
//Use automatic indentation for readability. writer.Formatting = Formatting.Indented;
//Write the root element writer.WriteStartElement("Schedule");
//Start an element
writer.WriteStartElement("Title");
//add sub-elements
writer.WriteElementString("Programme", myString);
//writer.WriteElementString("Time", "09:00");
//End the item element
writer.WriteEndElement();
// end the root element
//writer.WriteFullEndElement();
//Write the XML to file and close the writer
writer.Flush();
writer.Close();
}
i've placed this code within the foreach loop!! i'm not sure if this is right any ways the out come is not what i wanted it to be,
[ it creates an xml file with only one element string and ignores all other ones].
<Schedule>
<Title>
<Programme>Up All Night</Programme>
</Title>
</Schedule>
please i need a tip from an expert...
thanks and regards