Solved

VB.Net and XML XSD Files

Posted on 2016-08-21
1
43 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now