开发者

Displaying XML schema elements in treeview in order of appearance in XML

开发者 https://www.devze.com 2023-03-21 20:15 出处:网络
I need to display XSD files in a treeview. I already found one solution for this here!, but this just displays all the nodes in the file in the order they appear.

I need to display XSD files in a treeview. I already found one solution for this here!, but this just displays all the nodes in the file in the order they appear.

What I need is to display them in the order they appear in the XML file, and nested under the elements they will be nested under in the XML file:

<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="cat" type="xs:string"/>
    <xs:element name="dog" type="xs:string"/>

    <xs:element name="pets">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element ref="cat"/>
          <xs:element ref="dog"/>
        </xs:choice>
      &开发者_如何学编程lt;/xs:complexType>
    </xs:element>
</xs:schema>

Would be displayed like this:

-Pets
 -Dogs
 -Cats

How do I undentify the root node? I think that once I got that I can recurse into each type in the root elemet to find its name.

I am looking at this XSD specifically!. Should I start from the element called 'Document'? It contains the 2 top level elements in this type of file - 'GrpHdr' and 'OrgnlGrpInfAndSts'.

Is this is a standard way to tackle something like this?


Apparently there isn't since an XSD may contain more then 1 root element.

0

精彩评论

暂无评论...
验证码 换一张
取 消