如何对一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);
}
相关文档:
1、mian.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="HTTPSrv.send();" width="242" height="442">
<mx:Script>
<!--[CDATA[
import mx.rpc.events.ResultEv ......
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文件
/// ......
1.添加命名空间引用
using System.Xml;
2.新建xml实例
public XmlDocument objXmlDoc = new XmlDocument();
3.加载Xml文档
string path=Server.Mappath("demo.xml");//得到文档路径
objXmlDoc.Load(path);//加载文档
4.查找要进行操作的结点
objXmlDoc.SelectNodes(xpath);//得到结点集合
objXmlDoc.SelectSingleN ......
大家都知道在SQL Server中利用 FOR XML PATH 语句能够把查询的数据生成XML数据,下面是它的一些应用示例。
DECLARE @TempTable table(UserID int , UserName nvarchar(50));
insert into @TempTable (UserID,UserName) values (1,'a')
insert into @TempTable (UserID,UserName) values (2,'b')
select UserID, ......
XML 序列化可以采用从简单到复杂的多种形式。例如,可以序列化只包含公共字段和公共属性的类,如 XML 序列化简介中所示。下面的代码示例讨论各种高级方案,包括如何使用 XML 序列化生成符合特定 XML 架构 (XSD) 文档的 XML 流。
序列化数据集
除了序列化公共类的实例外,还可序列化 DataSet 的实例,如下面的代码示例所示 ......