xmlreader问题
我想讲一个xml格式的字符串转换成一个xml但总是转换出一半的数据,第一条,第三条,五。。。。。我想用xmlreader解决下,请各位大侠帮帮忙 ~ ~
string str1 =
"<?xml version=\"1.0\" encoding=\"GB2312\"?><ROOT>" +
"<R><GWBM>CC001</GWBM><GWMC>A</GWMC><CKBM/></R>" +
"<R><GWBM>JH003</GWBM><GWMC>B</GWMC><CKBM/></R>" +
"<R><GWBM>JH006</GWBM><GWMC>C</GWMC><CKBM/></R>" +
"<R><GWBM>JH007</GWBM><GWMC>D</GWMC><CKBM/></R>" +
"<R><GWBM>JH008</GWBM><GWMC>E</GWMC><CKBM/></R>" +
"<R><GWBM>LG005</GWBM><GWMC>F</GWMC><CKBM/></R>" +
"<R><GWBM>LG006</GWBM><GWMC>G</GWMC><CKBM/></R>" +
"<R><GWBM>LG011</GWBM><GWMC>H</GWMC><CKBM/></R>" +
"<R><GWBM>LT003</GWBM><GWMC>I</GWMC><CKBM/></R>" +
"<R><GWBM>SJ003</GWBM><GWMC>J</GWMC><CKBM/></R>" +
"<R><GWBM>SJ005</GWBM><GWMC>K</GWMC><CKBM/></R>" +
"<R><GWBM>XT001</GWBM><GWMC>L</GWMC><CKBM/></R>" +
"<R><GWBM>YL006</GWBM><GWMC>M</GWMC><CKBM/></R>" +
"<R><GWBM>YL007</GWBM><GWMC>N</GWMC><CKBM/></R>" +
"<R><GWBM>YL009</GWBM><GWMC>O</GWMC><CKBM/></R>" +
"<R><GWBM>ZX004</GWBM><GWMC>P</GWMC><CKBM/></R>" +
"<R><GWBM>ZX005</GWBM><GWMC>Q</GWMC><CKBM/></R>" +
"<R><GWBM>ZX006</GWBM><GWMC>R</GWMC><CKBM/></R></ROOT>";
TextReader treader = new StringReader(str);
XmlReader reader = XmlReader.Create(treader);
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "R")
{
Console.WriteLine(reader.ReadOuterXml());
}
}
补充:.NET技术 , C#