VB.Net and XML Example

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am looking for some sample code taht iterates through an XML document in VB.Net

I have never used XMl and need to get an example so I can start working with it

Thanks
CG.
 
Here's some XML...

<AdjudicationEngineConfiguration>
<PlugIn Assembly="C:\Documents and Settings\amarshall\Desktop\Andrew\Claims
Tool\New Adjudication Engine\Design\Code\Claims Tool Adjudication
Plug-In\bin\Claims Tool Adjudication Plug-In.dll"
Namespace="HarmonyIS.ClaimsTool.AdjudicationEnginePlugIn">
<RuleFactory Class="ClaimRuleFactory"/>
<QuestionFactory Class="ClaimQuestionFactory"/>
</PlugIn>
</AdjudicationEngineConfiguration>

Here's some semi-crappy code that read the previous XML...

Dim AssemblyFileName, PlugInNamespace _
, RuleFactoryClassName, QuestionFactoryClassName _
As String

'Read configuration file for assembly and class information
Dim XMLDoc As Xml.XmlDocument = New Xml.XmlDocument()
XMLDoc.Load("Adjudication Engine Configuration.xml")

'TODO: Add error handling if file does not exist

With XMLDoc.SelectSingleNode("AdjudicationEngineConfiguration")
With .SelectSingleNode("PlugIn")
AssemblyFileName = .Attributes("Assembly").Value
PlugInNamespace = .Attributes("Namespace").Value
With .SelectSingleNode("RuleFactory")
RuleFactoryClassName = .Attributes("Class").Value
End With
With .SelectSingleNode("QuestionFactory")
QuestionFactoryClassName = .Attributes("Class").Value
End With
End With
End With

Don't forget to reference System.XML.

That should get you started.

Andrew J. Marshall
MCP (Visual Basic)
Fairfax, VA
 
Back
Top