Solved

VB.Net and XML XSD Files

Posted on 2016-08-21
1
70 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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