zoukankan      html  css  js  c++  java
  • Xml Schema:C#访问在complextype中插入新元素

    最近用c#写Xml Schema代码,找了很久也找不到如何在已有的complextype中插入新的element,最后我充分发挥自己的聪明才智,哈哈,终于从...中找到了灵感。
    

    XmlSchemaSet xmlSSet;
    foreach( XmlSchema schema in xmlSSet.Schemas())
    {
    XmlSchemaElement  xmlSchRootElement = (XmlSchemaElement )schema.Items[0];//schema里面只能看到根节点元素,complextype里面的东西需要下一步提取
    XmlSchemaComplexType xmlSchComlex = (XmlSchemaComplexType)xmlSchRootElement.ElementSchemaType;//这一步最关键,找到complextype的对象
    XmlSchemaSequece xmlSchSeq = (XmlSchemaSequece)xmlSchComlex.Particle;//找到相应的元素
    XmlSchemaElement  xmlSchNewE =new XmlSchemaElement  ();
    
    xmlSchNewE.Name ="name";
    
    xmlSchNewE.SchemaTypeName = new XmlQualifiedName("unsignedByte",http://www.w3.org/2001/XMLSchema);
    
    try
    
    {
    
    xmlSeq.Items.Insert(0,xmlSchNewE);//0为索引,自已改
    
    xmlSSet.Reprocess(schema);//这个是为了保障更改后xmlSSet重新识别
    
    }
    
    catch()
    
    ...
     
     
    }
  • 相关阅读:
    java
    java
    informix资料下载
    linux下vim更改注释颜色
    linux修改目录颜色
    Centos下将sh脚本变为可全局运行的方法
    CentOS7启动时自动加载内核模块
    lsmod,depmod,modprobe,modinfo,insmod,rmmod
    自旋锁与信号量
    软中断、tasklet和工作队列
  • 原文地址:https://www.cnblogs.com/joean/p/4982876.html
Copyright © 2011-2022 走看看