Solved

VB.Net and XML XSD Files

Posted on 2016-08-21
1
58 Views
Last Modified: 2016-08-27
I am wondering if there is a simple way to parse an XSD file and extract the folowing

a) a list of all simpleType elements. I would like to get the Name, the RestrictionBase, MinLength, MaxLength and if posible the list of enumeration.

b)  a list of all complexTypes and all elements in the sequence with Name, type, min and Max Occurrence

I enclosed a sample file
cfs_billing.xsd
0
Comment
Question by:AlexPonnath
1 Comment
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 41765425
Just some code to get you started. You can find HtmlAgilityPack in the free Nuget packages that you can install.
Of course I can try to finish the whole working code, but I'm assuming you can finish it by yourself using the code provided. If not, check output first, and feedback on what you need.

Imports HtmlAgilityPack


Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim doc As New HtmlDocument()

        doc.Load("C:\Users\Kimputer\Downloads\cfs_billing.xsd.txt")



        For Each node In doc.DocumentNode.SelectNodes("schema")
            Dim counter = 1

            For Each node2 In node.SelectNodes("simpletype")
                TextBox1.AppendText("Enumerate " & counter.ToString & vbCrLf)
                Dim test = node2.Attributes("name")
                TextBox1.AppendText("simpletype name = " & test.Value & vbCrLf)
                Dim nodetest = node2.SelectNodes("restriction")
                If Not (IsNothing(nodetest)) Then
                    For Each node3 In node2.SelectNodes("restriction")
                        Dim test2 = node3.Attributes("base")
                        TextBox1.AppendText("restriction base = " & test2.Value & vbCrLf)
                    Next
                End If

                counter = counter + 1
            Next
        Next
        


    End Sub
End Class

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question