Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VISUAL BASIC - Trying to find XPATH values?

  • 05-10-2005 12:28PM
    #1
    Registered Users, Registered Users 2 Posts: 5,103 ✭✭✭


    Hi

    I am trying to give a function an XPATH and a DOM object and return a specific value.

    For instance if I do

    GetFormValueFromXMLFile("//QuarterlyInsuranceReturn/St1/InsuranceContract/NumberofPolicies/@TWO", oXMLDoc)
    I should get 2 (xml file is below)


    Any ideas?
    Thanks guys



    Function GetFormValueFromXMLFile(strXMLQuery As String, oXMLDoc As FreeThreadedDOMDocument)

    Dim objNodeList, i
    Dim strText As String

    Text1.Text = Text1.Text & "strXMLQuery Is " & strXMLQuery & vbCrLf
    'Set objNodeList = oXMLDoc.documentElement.selectNodes(strXMLQuery)
    'Set objNodeList = oXMLDoc.documentElement.selectSingleNode(strXMLQuery)

    GetFormValueFromXMLFile = 17 'just to make the code compile

    End Function





    <?xml version="1.0" encoding="UTF-8" ?>
    <QuarterlyInsuranceReturn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation="\\Server1\XML Schema\QuarterlyInsuranceSchema.xsd">
    <submissionDetails submissionCompany="ADRIATIC" quarter="Quarter 1" submissionYear="2005" />
    <St1>
    <InsuranceContract>
    <NumberofPolicies FIVE="4" FOUR="3" SIX="5" THREE="2" EIGHT="7" TEN="9" SEVEN="6" NINE="8" TWO="1" />
    <NumberofInsured FIVE="40" FOUR="30" SIX="50" THREE="20" EIGHT="70" TEN="90" SEVEN="60" NINE="80" TWO="10" />
    <PremiumWritten FIVE="400" FOUR="300" SIX="500" THREE="200" EIGHT="700" TEN="900" SEVEN="600" NINE="800" TWO="100" />
    </InsuranceContract>
    <Claims>
    <NumberofOneoffClaims FIVE="4000" FOUR="3000" SIX="5000" THREE="2000" EIGHT="7000" TEN="9000" SEVEN="6000" NINE="8000" TWO="1000" />
    <NumberofInstallmentPaymentClaims FIVE="40000" FOUR="30000" SIX="50000" THREE="20000" EIGHT="70000" TEN="90000" SEVEN="60000" NINE="80000" TWO="10000" />
    <GrossClaimsPaidInOneOffAmount FIVE="400000" FOUR="300000" SIX="500000" THREE="200000" EIGHT="700000" TEN="900000" SEVEN="600000" NINE="800000" TWO="100000" />
    <GrossClaimsPaidIstallmentPayments FIVE="4000000" FOUR="3000000" SIX="5000000" THREE="2000000" EIGHT="7000000" TEN="9000000" SEVEN="6000000" NINE="8000000" TWO="1000000" />
    </Claims>
    </St1>
    </QuarterlyInsuranceReturn>


Advertisement