GetAttributeValue()

Top  Previous  Next

Object: EHL7.QSXML

FileName: EHL7.dll

 

METHOD

 

Name: GetAttributeValue()

Parameters:

1.objNode (Object)
2.strAttribute (String) the name of the attribute (case sensitive)
3.strDefault (Optional String = "") a default value to return if the Attribute does not exist.

Returns: String

Description: This method returns the value of a named attribute on an xml node object or strDefault if it does not exist.

 

See Also: VendorsXML(), SetAttribute()

 

Example to Populate a VB listbox with vendors to allow user selection:

'1) Create a blank form and place a listbox control on it called listbox1

'In the form declaration area

Private myVendorsXML As String

 

Private Sub Form_Load()

Dim myVendorObj As New EHL7.HL7Vendors

Dim oXML As New EHL7.QSXML

Dim ndRT As Object

Dim ndLst As Object

Dim i As Long

Dim sBuff As String

Dim strVendorID As String

myVendorObj.VendorPath = "C:\EasyHL7"

myVendorsXML = myVendorObj.VendorsXML()

If myVendorsXML = "" Then

    MsgBox myVendorObj.LastError

    Exit Sub

End If

oXML.OpenFromString(myVendorsXML)

Set ndRT = .GetRootElement()

If CLng(.GetAttributeValue(ndRT,"COUNT","0")) = 0 Then

    MsgBox "No Vendors Installed"

    Exit Sub

End If

Set ndLst = .GetRootChildren

For i = 0 To ndLst.Length - 1

   sBuff = .GetAttributeValue(ndLst(i),"NAME") & _

           " (Version " & .GetAttributeValue(ndLst(i),"VERSION") & ")"

   listbox1.AddItem sBuff

   'We'll use the item data property to store the index so

   'you can set the .sorted property on the listbox to True if desired

   listbox1.ItemData(listbox1.NewIndex) = i

Next

Set myVendorObj = Nothing

Set oXML = Nothing

End Sub

'Now add DblClick code to the listbox

Private Sub listbox1_DblClick()

Dim myVendorObj As New EHL7.HL7Vendors

Dim oXML As New EHL7.QSXML

Dim ndRT As Object

Dim ndLst As Object

Dim i As Long

Dim idxSel As Long

Dim strVendorID As String

'Get our node index for the selected vendor

idxSel = listbox1.ItemData(listbox1.ListIndex)

myVendorObj.VendorPath = "C:\EasyHL7"

With oXML

       'Load the vendors xml we saved in form_load

     .OpenFromString(myVendorsXML)

     'Get the root children

     Set ndLst = .GetRootChildren()

     'NOW WE KNOW WHICH VENDOR THE USER CLICKED

     strVendorID = .GetAttributeValue(ndLst(idxSel),"ID")

     MsgBox "The user selected Vendor ID: " & strVendorID

End With

With myVendorObj

    Call .OpenVendor(strVendorID)

    'etc

    'etc

End With

 

End Sub

 

Example XML String:

<VENDORS COUNT="3">

<VENDOR ID="63578DEA-9541-4663-B484-111919054FBC" NAME="Default"

DESCRIPTION="EasyHL7 default vendor for version 2.3" VERSION="2.3" FIELDSEPARATOR="|"

ENCODINGCHARS="^~\&" PARSINGCHARS="0B|1C,0D|0D"/>

<VENDOR ID="10D80A28-6A2C-4AD3-8080-32924F02F0CE" NAME="Default"

DESCRIPTION="" VERSION="2.4" FIELDSEPARATOR="|"

ENCODINGCHARS="^~\&" PARSINGCHARS="0B|1C,0D|0D" />

<VENDOR ID="5ABE45FC963631449F077FA15F28E69B" NAME="Labcorp"

DESCRIPTION="Labcorp vendor created by me" VERSION="2.3" FIELDSEPARATOR="|"

ENCODINGCHARS="^~\&" PARSINGCHARS="0B|1C,0D|0D" />

</VENDORS>