如何对一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.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
public class Cls_XML
{
#region 创建xml文件
/// <summary>
/// 创建xml文件
/// ......
XML中一种扩展的标记语言,它具有很好的扩展性标记.本文通过XML实现不同数据库的定义,实现对XML数据库的访问和异构数据库之间的互访.
关键词:XML 异构数据库 信息交换 数据库访问
1 引言
XML(Extensible Markup Language)它是由W3C组织于1998年2月 &nb ......
package com.test.dom4j;
import java.io.*;
import java.util.*;
import org.dom4j.*;
import org.dom4j.io.*;
public class MyXMLReader {
public static void main(String arge[]) {
try {
File f = new File("src/testxml.xml");
SAXReader reader = new SAXReader();
Document doc = reader.rea ......
接上一篇《C#写XML的简单例子》
这个例子要修改XML文件中结点的属性和和元素的文本
1 原xml文件 bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="love" ISBN="1234123">
<title>who am i </title>
&l ......
接上一篇
显示所有结点的内容
1 原xml文件 bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book ISBN="1234123">
<title>who am i </title>
<author>who</author>
<price> ......