易截截图软件、单文件、免安装、纯绿色、仅160KB

格式化XML:输出有缩进效果的XML字符串

1. 一般情况下使用以下代码即可将XML字符串重新格式化:
        private string FormatXml(string source)
        {
            StringBuilder sb = new StringBuilder();
            XmlTextWriter writer = null;
            
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(source);
                writer = new XmlTextWriter(new StringWriter(sb));
                writer.Formatting = Formatting.Indented;
                
                doc.WriteTo(writer);
            }
            finally
            {
                if (writer != null) writer.Close();
            }
         


相关文档:

LINQ TO XML Common Class

个人收集、整理了一些LINQ TO XML的基本方法,希望各位大虾多多指导:
 /// <summary>
///Xml节点属性
/// </summary>
public class XmlAttribute
{
 public XmlAttribute()
 {
  
 }
    public XmlAttribute(string _key,object _value)
 &nbs ......

用Dom4j来解析xml文件

package com.pk.xml;
import java.io.File;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class Dom4j {
public static void main(String[] args) {
try {
//获得SAX解析器
SAXReader reader = new SAXReader();

//解析文件
File file = n ......

OpenXml开发 一个应用Xml的例子


  3private XmlDocument xmlDoc;
  4        //load xml file
  5        private void LoadXml()
  6        { ......

CMarkup与tinyXml直接解析XML字符串

今天才知道CMarkup可以直接解析字符串形式的XML。以前都是先存入一个文件,然后从文件中load。多做了I/O操作,效率不高。
CMarkup xml;
CString str;
xml.SetDoc(str);
tinyXml也可以直接解析XML字符串,方式如下:
// directly parsing string with tinyxml   
const char* ......

jms xml namespace

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:amq="http://activemq.org/config/1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/bea ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号