I am needing help getting started on what should be a simple project. I need to read one xml file, validate some of the data then write the same file plus an inserted status line out to another xml file… simple right? Well, bear in mind that I have not used xml files before and have only tinkered with .NET
Here is some code that I think is right to read the file:
Here is some code that I think is right to read the file:
Code:
Option Explicit On
Option Strict Off
Imports System.Xml
Imports System
Imports System.Xml.XmlDataDocument
Imports System.Xml.XmlAttributeCollection
Imports System.IO
Imports System.String
Imports System.Runtime.InteropServices
Imports System.EnterpriseServices
Imports Microsoft.BizTalk
Imports Microsoft.BizTalk.BTSComponentsLib
Imports System.Data.SqlClient
Private Function Process(ByVal bstrDocument As String) As String
Dim xDoc As New XmlDocument()
Dim xRoot As XmlElement
Dim xDocType As String
‘my connection is here to the db
xDoc.LoadXml(bstrDocument)
xRoot = xDoc.DocumentElement
ProcessFile(xRoot)
‘connection is closed here
[COLOR=red]‘Will this work to write out the new file???[/color]
xDoc.WriteTo(path here)
Exit Function
Private Function ProcessFile(ByVal xRoot As XmlElement)
‘have code here to dim variables
[COLOR=red]‘is this loading the xml correctly????[/color]
xSources = xRoot.GetElementsByTagName("TS_2000A")
For Each xSource In xSources
xSourceInfo = xSource.GetElementsByTagName("TS_2100A").Item(0)
xReceivers = xSource.GetElementsByTagName("TS_2000B")
For Each xReceiver In xReceivers
xReceiverInfo = xReceiver.GetElementsByTagName("TS_2100B").Item(0)
xCompanies = xSource.GetElementsByTagName("TS_2000C")
For Each xCompany In xCompanies
xCompaniesInfo = xCompany.GetElementsByTagName("TS_2100C").Item(0)
xMembers = xSource.GetElementsByTagName("TS_2000D")
For Each xMember In xMembers
xMemberInfo = xMember.GetElementsByTagName("TS_2100D").Item(0)
subIdentCode = GetAttribute(xMemberInfo, "EntityIdentifierCode")
subLastName = GetAttribute(xMemberInfo, "MemberLastName")
subFirstName = Left(GetAttribute(xmemberInfo, "MemberFirstName"), 2)
subMiddleInitial = Left(GetAttribute(xMemberInfo, "MiddleInitial"), 1)
subDOB = GetAttribute(xMemberInfo, "Birthdate")
subGender = GetAttribute(xMemberInfo, "Gender")
Next
Next
Next
Next
Now where do I validate that the MemberInfo (first, last, DOB, etc) is valid?
My output xml file should look exactly the same with just some additional lines for the status of this member, then should loop through until done….
I have never worked with xml files before so please bear with me…. I am hoping to catch on quickly since I really don’t have a choice….
If there is a simpler way or someone has a better idea, please let me know.
Thanks for any insights!
A