• 大小: 36KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-23
  • 语言: C#
  • 标签: xml  Schema  C#  

资源简介

xml Schema 例子(C#写的验证程序)QQ:292258449

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.xml;
using System.IO;
using System.xml.Schema;

namespace DOMExample5
{
    class Program
    {
        #region  1

        //[STAThread]
        //static void Main(string[] args)
        //{

        //    xmlDocument document = new xmlDocument();
        //    document.Load(“..\\..\\xmlFile1.xml“);
        //    Console.WriteLine(“元素是:“);
        //    PrintElement(document);

        //    Console.WriteLine(“元素的属性是:“);
        //    PrintElementAttributes(document);

        //    Console.Read();
        //}

        //private static void PrintElement(xmlDocument document)
        //{
        //    xmlNodeList nodeList = document.GetElementsByTagName(“*“);
        //    for (int i = 0; i < nodeList.Count; i++)
        //    {
        //        xmlNode node = nodeList.Item(i);
        //        Console.Write(node.Name + “ “);
        //    }
        //}

        //private static void PrintElementAttributes(xmlDocument document)
        //{
        //    xmlNodeList nodeList = document.GetElementsByTagName(“*“);
        //    xmlNamedNodeMap namedNodeMap;
        //    xmlElement element;
        //    xmlAttribute attribute;
        //    string attributeName;
        //    string attributeValue;

        //    for (int i = 0; i < nodeList.Count; i++)
        //    {
        //        element = (xmlElement)nodeList.Item(i);
        //        Console.WriteLine(element.Name + “:“ + element.ChildNodes[0].Value);
        //        namedNodeMap = element.Attributes;
        //        if (namedNodeMap != null)
        //        {
        //            for (int j = 0; j < namedNodeMap.Count; j++)
        //            {
        //                attribute = (xmlAttribute)namedNodeMap.Item(j);
        //                attributeName = attribute.Name;
        //                attributeValue = attribute.Value;
        //                Console.WriteLine(“属性是:“ + attributeName + “ = “ + attributeValue);
        //            }
        //        }

        //    }
        //} 
        #endregion

        #region 2

        //[STAThread]
        //static void Main(string[] args)
        //{

        //    xmlDocument document = new xmlDocument();
        //    try
        //    {
        //        document.Load(“..\\..\\xmlFile1.xml“);
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e.Message);
        //        return;
        //    }

        //    Console.WriteLine(“元素是:“);
        //    PrintElements(document);

        //    Console.WriteLine(“每个元素的属性:“);
        //    PrintElementAttributes(document);

        //    Console.Read();

        //}

        //private static void PrintElements(xmlDocument document)
        //{
        //    xmlNodeList nodeList = document.GetElementsByTagName(“*“);
        //

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       8192  2010-06-24 13:06  DOMExample5\DOMExample5\bin\Debug\DOMExample5.exe

     文件      19968  2010-06-24 13:06  DOMExample5\DOMExample5\bin\Debug\DOMExample5.pdb

     文件      14328  2010-06-24 13:43  DOMExample5\DOMExample5\bin\Debug\DOMExample5.vshost.exe

     文件        490  2007-07-21 01:33  DOMExample5\DOMExample5\bin\Debug\DOMExample5.vshost.exe.manifest

     文件       2756  2010-06-24 12:21  DOMExample5\DOMExample5\DOMExample5.csproj

     文件        168  2010-06-03 21:27  DOMExample5\DOMExample5\DOMExample5.csproj.user

     文件       1445  2010-06-24 13:43  DOMExample5\DOMExample5\obj\Debug\DOMExample5.csproj.FileListAbsolute.txt

     文件       8192  2010-06-24 13:06  DOMExample5\DOMExample5\obj\Debug\DOMExample5.exe

     文件      19968  2010-06-24 13:06  DOMExample5\DOMExample5\obj\Debug\DOMExample5.pdb

     文件      10757  2010-06-24 13:06  DOMExample5\DOMExample5\Program.cs

     文件       1378  2010-06-03 21:12  DOMExample5\DOMExample5\Properties\AssemblyInfo.cs

     文件       4286  2010-06-23 12:41  DOMExample5\DOMExample5\TestSchema.cs

     文件        463  2010-06-23 12:54  DOMExample5\DOMExample5\xmlFile1.xml

     文件        543  2010-06-23 12:55  DOMExample5\DOMExample5\xmlFile2.xml

     文件        875  2010-06-24 14:59  DOMExample5\DOMExample5\xmlFile3.xml

     文件       2184  2010-06-24 12:05  DOMExample5\DOMExample5\xmlSchema1.xsd

     文件       2273  2010-06-23 12:54  DOMExample5\DOMExample5\xmlSchema2.xsd

     文件       4068  2010-06-24 14:59  DOMExample5\DOMExample5\xmlSchema3.xsd

     文件        440  2010-06-03 23:19  DOMExample5\DOMExample5\复件 xmlFile1.xml

     文件       2154  2010-06-03 23:19  DOMExample5\DOMExample5\复件 xmlSchema1.xsd

     文件        923  2010-06-24 12:21  DOMExample5\DOMExample5.sln

    ..A..H.     20480  2010-06-24 15:05  DOMExample5\DOMExample5.suo

    .......        43  2010-06-24 12:15  DOMExample5\xmlFile1.xml

     目录          0  2010-06-24 11:39  DOMExample5\DOMExample5\obj\Debug\Refactor

     目录          0  2010-06-24 11:39  DOMExample5\DOMExample5\obj\Debug\TempPE

     目录          0  2010-06-24 12:24  DOMExample5\DOMExample5\bin\Debug

     目录          0  2010-06-24 13:06  DOMExample5\DOMExample5\obj\Debug

     目录          0  2010-06-24 11:39  DOMExample5\DOMExample5\bin

     目录          0  2010-06-24 11:39  DOMExample5\DOMExample5\obj

     目录          0  2010-06-24 11:39  DOMExample5\DOMExample5\Properties

............此处省略5个文件信息

评论

共有 条评论