我的代码如下:
XmlDocument xmldoc = new XmlDocument();
XmlElement root = xmldoc.CreateElement("annotion");
xmldoc.AppendChild(root); XmlElement filename = xmldoc.CreateElement("filename");//在annotion下添加filename
filename.InnerText = listBox1.SelectedItem.ToString();
root.AppendChild(filename); XmlElement segmented = xmldoc.CreateElement("segmented");
segmented.InnerText = "0";
root.AppendChild(segmented);
XmlElement source = xmldoc.CreateElement("source"); XmlElement database = xmldoc.CreateElement("database");
database.InnerText = "The VOC2008 Database";
source.AppendChild(database); XmlElement image = xmldoc.CreateElement("image");
image.InnerText = "flickr";
source.AppendChild(image); root.AppendChild(source); xmldoc.Save(Filename);生成的xml文件以网页的形式打开之后,可以看到子节点相对于父亲节点是有缩进的,是不是这个空白的地方造成的不可解析?因为如果手动删除空白的地方之后,又可以解析了。我想问的是,这些空白是自动生成的,怎么解决呢?
解析程序解析空白时只能解析:tab, line feed, vertical tab, form feed, carriage return, and space
XmlDocument xmldoc = new XmlDocument();
XmlElement root = xmldoc.CreateElement("annotion");
xmldoc.AppendChild(root); XmlElement filename = xmldoc.CreateElement("filename");//在annotion下添加filename
filename.InnerText = listBox1.SelectedItem.ToString();
root.AppendChild(filename); XmlElement segmented = xmldoc.CreateElement("segmented");
segmented.InnerText = "0";
root.AppendChild(segmented);
XmlElement source = xmldoc.CreateElement("source"); XmlElement database = xmldoc.CreateElement("database");
database.InnerText = "The VOC2008 Database";
source.AppendChild(database); XmlElement image = xmldoc.CreateElement("image");
image.InnerText = "flickr";
source.AppendChild(image); root.AppendChild(source); xmldoc.Save(Filename);生成的xml文件以网页的形式打开之后,可以看到子节点相对于父亲节点是有缩进的,是不是这个空白的地方造成的不可解析?因为如果手动删除空白的地方之后,又可以解析了。我想问的是,这些空白是自动生成的,怎么解决呢?
解析程序解析空白时只能解析:tab, line feed, vertical tab, form feed, carriage return, and space
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货