如何对一xml格式的字符串分析?
http://topic.csdn.net/t/20021102/16/1142056.html
use classes in System.Xml namespace, for example (assume your xml is in string s and it contains an xmlns definition):
<ns:vi id="New_main" xmlns:ns="whatever">
<ns:node Expandable="checkOnce" Selected="true" ID="a1">
root<ns:node ID="a2">
Node1
</ns:node>
</ns:node>
</ns:vi>
string s = "................";
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(s);
XmlNamespaceManager xnm = new XmlNamespaceManager(xmldoc.NameTable);
xnm.AddNamespace("ns","whatever");
XmlNode node = xmldoc.SelectSingleNode("//ns:node[@ID='a1']", xnm);
if (node != null)
{
XmlAttribute att = xmldoc.CreateAttribute("bbi");
att.Value = "xxxxxxxxxxx";
node.Attributes.Append(att);
}
相关文档:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Syste ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
public class Cls_XML
{
#region 创建xml文件
/// <summary>
/// 创建xml文件
/// ......
调试时发现日志报如下错误 org.xml.sax.SAXParseException
发现是xml对特殊符号要做处理,几个特殊符号如下:
< < 小于号
> > 大于号
& & 和
' ' 单引号
" " 双引号
在xml中把特殊符号用上述转下即好了 ......
序列化是将对象转换成易于传输的形式的过程。例如,可以序列化对象,并使用 HTTP 通过 Internet 在客户端和服务器之间进行传输。另一方面,反序列化在流中重新构建对象。
XML 序列化只将对象的公共字段和属性值序列化为 XML 流。XML 序列化不包括类型信息。例如,如果 Library 命名空间中存在 Book 对象,则不能保证将它反 ......
接上一篇
删除原genre属性,删除leixing=love的所有结点。
1 原xml文件 bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="love" ISBN="1234123">
<title>who am i </title>
<author>who</aut ......