【C# XML 】XML Shcema 案例


框架

<?xml version="1.0" encoding="utf-8"?>
"Stocks"
    targetNamespace="http://tempuri.org/Stocks"
    elementFormDefault="qualified"
    xmlns:this="http://tempuri.org/Stocks"
    xmlns="http://www.w3.org/2001/XMLSchema"
           
>

    
    
    
    "OpenPrice" type="this:PriceRang"  />
    "ClosePrice" type="this:PriceRang"/>
    "HightPrice" type="this:PriceRang"/>
    "LowPrice" type="this:PriceRang"/>

    "KLine" type="this:OCHLElement"  />
    
    
    "PriceRang">
        base="decimal">
            "0">
            "100000000000">
        
    


    
    "OCHLElement" mixed="true"  >
        
            ref="this:OpenPrice" maxOccurs="1"/>
            ref="this:ClosePrice" maxOccurs="1"/>
            ref="this:HightPrice" maxOccurs="1"/>
            ref="this:LowPrice" maxOccurs="1"/>

        

    


        
    "Stock" type="this:stock" />
    
        
    "stock"   >
        
            ref="this:Company" maxOccurs="1"/>
                 ref="this:KLine" maxOccurs="unbounded"/>
        
    

    
    
    
    
        
    "Company" type="this:CompanyNameRang" />
    
        
    "CompanyNameRang">
        base="string">
            "[a-zA-Z][a-zA-Z][a-zA-Z]+"/>
        

    


框架解释

建立一个k线 框架。

实例

用已经定义的Stock框架 ,建立实例文档

<?xml version="1.0" encoding="utf-8" ?>
"http://tempuri.org/Stocks">
    tengXun

    
        15
        15.54
        15.90
        14.90
        
    
    
        16
        17.54
        17.54
        15.90

    

 
C