StreamReader sr = new StreamReader(@"E:/a.txt");
String line = "";
int i = 1;
XmlTextWriter xw = new XmlTextWriter(@"E:\xingce.xml", Encoding.UTF8);
xw.WriteStartDocument();
xw.Formatting = Formatting.Indented;
while ((line = sr.ReadLine()) != null)
{
if (line.Trim().StartsWith("【"))
{
xw.WriteStartElement("Topic");
xw.WriteValue("\n");
xw.WriteStartElement("Id");
xw.WriteValue("\n");
xw.WriteValue(i++);
xw.WriteValue("\n");
xw.WriteEndElement();
xw.WriteValue("\n");
xw.WriteStartElement("Question");
xw.WriteValue("\n");
xw.WriteValue(line);
xw.WriteValue("\n");
xw.WriteValue(sr.ReadLine());
xw.WriteValue("\n");
xw.WriteEndElement();
xw.WriteValue("\n");
}
else if(line.Trim().StartsWith("A"))
{
xw.WriteValue(line);
xw.WriteValue("\n");
}
else if (line.Trim().StartsWith("分析"))
{
xw.WriteStartElement("Answer");
xw.WriteValue("\n");
xw.WriteValue(line);
xw.WriteValue("\n");
}
else if (line.Trim()== "")
{
xw.WriteValue("\n");
xw.WriteEndElement();
xw.WriteValue("\n");
}
else
{
xw.WriteValue(line);
xw.WriteValue("\n");
}
}
xw.WriteEndElement();
xw.Flush();
xw.Close();
【1】7,9,-1,5,( )
A、4;B、2;C、-1;D、-3
分析:选D,7+9=16; 9+(-1)=8;(-1)+5=4;5+(-3)=2 , 16,8,4,2等比
<Id>
1
</Id>
<Question>
【1】7,9,-1,5,( )
A、4;B、2;C、-1;D、-3
</Question>
<Answer>
分析:选D,7+9=16; 9+(-1)=8;(-1)+5=4;5+(-3)=2 , 16,8,4,2等比
</Answer>