Solved

VB.Net and XML XSD Files

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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