zoukankan      html  css  js  c++  java
  • 简单xml示例

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml;
    using System.Xml.Linq;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string dataxml = @"
    <Products>
    <Product>
    <ProductID>1</ProductID>
    <ProductName>LINQ to XML</ProductName>
    <UnitPrice>10</UnitPrice>
    </Product>
    <Product>
    <ProductID>2</ProductID>
    <ProductName>LINQ to SQL</ProductName>
    <UnitPrice>20</UnitPrice>
    </Product>
    </Products>";
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(dataxml);
                XmlElement root=doc.DocumentElement;
                XmlNodeList objxml = root.SelectNodes("/Products/Product");
                foreach (XmlNode e in objxml)
                {
                    Console.WriteLine("{0}-{1}-{2}", e.SelectSingleNode("ProductID").InnerText, e.SelectSingleNode("ProductName").InnerText, e.SelectSingleNode("UnitPrice").InnerText);               
                }
                Console.ReadLine();
            }
        }
    }
    View Code
  • 相关阅读:
    【Linux 读书笔记】Linux文件的硬连接和符号连接
    Shell参数
    Shellcase语句的例子
    Shellselect
    Shell小程序一个
    SHELL起步
    接昨天的 while
    Shell循环控制
    Shellwhile循环的例子
    Shellfor语句
  • 原文地址:https://www.cnblogs.com/myloveblogs/p/5582953.html
Copyright © 2011-2022 走看看