惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
D
Docker
有赞技术团队
有赞技术团队
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
H
Help Net Security
美团技术团队
MyScale Blog
MyScale Blog
B
Blog RSS Feed
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
G
Google Developers Blog
月光博客
月光博客
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs

博客园 - gamebaby

去掉rhel 6的缺少授权证书提示 c++消息 脚踏实地向前走 InvokeMember Invoke 项目经理应该知道的. Clear Sqlserver log 获取表信息 Email(VB.net) - gamebaby - 博客园 Email(C#) - gamebaby - 博客园 主外键 转义符 常规触发器 创建数据库 触发器 CASE 语句 事务处理 游标例子2(转载) 游标例子1(转载)
读xml内容 - gamebaby - 博客园
gamebaby · 2007-07-16 · via 博客园 - gamebaby

public string GetData()
        
{
            XmlDocument xmlDoc 
= new XmlDocument();
            xmlDoc.Load(file);
            XmlNodeList xnbase 
= xmlDoc.ChildNodes;

            
return bianli(xnbase);
        }

private string bianli(XmlNodeList xns)
        
{
            
string v = "";
            XmlElement xe 
= null;
            XmlCDataSection xc 
= null;
            XmlDeclaration xd 
= null;
            
foreach (XmlNode xnf in xns)
            
{
   
                
switch (xnf.NodeType)
                
{
                    
case XmlNodeType.XmlDeclaration:
                         xd 
= (XmlDeclaration)xnf;
                         v 
+= "<?" + xd.Name+" "+xd.InnerText + "?>\n";
                        
break;
                    
case XmlNodeType.CDATA:
                        xc 
= (XmlCDataSection)xnf;
                        v 
+= "<![CDATA[" + xc.Data + "]]>";
                        
break;
                    
case XmlNodeType.Element:
                        v 
+= "<" + xnf.Name;
                        xe 
= (XmlElement)xnf;
                        
foreach (XmlAttribute xa in xe.Attributes)
                        
{
                            v 
+= " " + xa.Name + "=\"" + xe.GetAttribute(xa.Name) + "\"";//显示属性值
                        }

                        v 
+= ">";
                        XmlNodeList xnf1 
= xe.ChildNodes;
                        v 
+= this.bianli(xnf1);
                        v 
+= "</" + xnf.Name + ">\n";
                        
break;
                    
case XmlNodeType.None:
                        
break;
                    
case XmlNodeType.Text:
                        v 
+= xnf.InnerText;
                        
break;
 
                }


            }

            
            
return v;
        }

 posted on 2007-07-16 08:28  gamebaby  阅读(214)  评论(0)    收藏  举报

刷新页面返回顶部