locked
How to read XML file from VB 6.0 RRS feed

  • Question

  • Hi all ,

     I was given a file as .xml with below data  


       

    <?xml version="1.0" encoding="UTF-8"?>

    <Globus xmlns="http://www.temenos.com/GLOBUS/OFSML/120" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.temenos.com/GLOBUS/OFSML/120 ../../xsd/ofsml.xsd"><ofsmlHeader ofsmlMajor="2" ofsmlMinor="2" ofsmlRelease="1"><requestChannel>Browser.1</requestChannel>

    <company>VN0010001</company>

    <requestId>bc7ae08a836e226bA2018acfd11fb731d23aA7fff</requestId>

    <requestTimeStamp>2009-02-27T17:05:25</requestTimeStamp>

    <responseTimeStamp>2009-02-27T17:05:25</responseTimeStamp>

    </ofsmlHeader>

    <serviceResponse>

    <ofsStandardEnquiry name="ACCOUNT-IBS" status="OK">

    <enquiryColumn globusType="STRING" id="ACCOUNT.NUMBER" label="ACCOUNT.NUMBER"/>

    <enquiryColumn globusType="STRING" id="CUSTOMER.ID" label="CUSTOMER.ID"/>

    <enquiryColumn globusType="STRING" id="CUST.NAME" label="CUST.NAME"/>

    <enquiryColumn globusType="STRING" id="ACCOUNT.OFFICER" label="ACCOUNT.OFFICER"/>

    <enquiryColumn globusType="STRING" id="TYPE" label="TYPE"/>

    <enquiryColumn globusType="STRING" id="CURRENCY" label="CURRENCY"/>

    <enquiryColumn globusType="STRING" id="ONLINE.ACTUAL.BAL" label="ONLINE.ACTUAL.BAL"/>

    <enquiryColumn globusType="STRING" id="WORKING.BALANCE" label="WORKING.BALANCE"/>

    <enquiryColumn globusType="STRING" id="LIMIT.AMOUNT" label="LIMIT.AMOUNT"/>

    <enquiryColumn globusType="STRING" id="POSTING.RESTRICT" label="POSTING.RESTRICT"/>

    <enquiryColumn globusType="STRING" id="MINIMUM.BALANCE" label="MINIMUM.BALANCE"/>

    <enquiryColumn globusType="STRING" id="USED.BALANCE" label="USED.BALANCE"/>

    <enquiryColumn globusType="STRING" id="LAST.TRANS.DATE" label="LAST.TRANS.DATE"/>

    <enquiryColumn globusType="STRING" id="ACCR.INTEREST" label="ACCR.INTEREST"/>

    <enquiryColumn globusType="STRING" id="STATUS" label="STATUS"/>

    <enquiryColumn globusType="STRING" id="TOTAL.CR.AMOUT" label="TOTAL.CR.AMOUT"/>

    <enquiryColumn globusType="STRING" id="TOTAL.DR.AMOUNT" label="TOTAL.DR.AMOUNT"/>

    <enquiryRecord>

    <column>002100000415</column>

    <column> 100297</column>

    <column>NGUYEN THI THANH VAN</column>

    <column>RETAIL </column>

    <column>1001-Tien gui</column>

    <column>VND</column><column> 18,007,200</column>

    <column>17957200</column><column>

    </column><column> </column>

    <column>50,000 </column>

    <column>17907200</column>

    <column>23 DEC 2008</column>

    <column>12005</column>

    <column> </column>

    <column>0 </column>

    <column>0</column>

    </enquiryRecord>

    </ofsStandardEnquiry>

    </serviceResponse>

    </Globus> 


    So this file data I have to read from VB6.0

       Till service Response  i am getting the values ..   

       

    Dim objDOMDocument As IXMLDOMDocument
    Dim root As IXMLDOMElement
    Dim objNodes As IXMLDOMNodeList
      Dim objBookNode As IXMLDOMNode
    Set objDOMDocument = New DOMDocument
    objDOMDocument.async = False
    objDOMDocument.Load "d:\XML\123XML.XML"
    Dim NodeValue

     Set objNodes = objDOMDocument.selectNodes("Globus")
       For Each objBookNode In objNodes
        If objBookNode.selectNodes("ofsmlHeader").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("ofsmlHeader").nodeTypedValue
             Debug.Print NodeValue
        End If
         If objBookNode.selectNodes("serviceResponse").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("serviceResponse").nodeTypedValue
             Debug.Print NodeValue
        End If
        Next objBookNode
    For Each objBookNode In objNodes
          If objBookNode.selectNodes("ofsmlHeader/requestChannel").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("ofsmlHeader/requestChannel").nodeTypedValue
             Debug.Print NodeValue
          End If
          If objBookNode.selectNodes("ofsmlHeader/company").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("ofsmlHeader/company").nodeTypedValue
             Debug.Print NodeValue
          End If
           If objBookNode.selectNodes("ofsmlHeader/requestId").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("ofsmlHeader/requestId").nodeTypedValue
             Debug.Print NodeValue
          End If
          If objBookNode.selectNodes("ofsmlHeader/requestTimeStamp").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("ofsmlHeader/requestTimeStamp").nodeTypedValue
             Debug.Print NodeValue
          End If
          If objBookNode.selectNodes("ofsmlHeader/responseTimeStamp").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("ofsmlHeader/responseTimeStamp").nodeTypedValue
             Debug.Print NodeValue
          End If
          If objBookNode.selectNodes("serviceResponse/ofsStandardEnquiry").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry").nodeTypedValue
             Debug.Print NodeValue
          End If
          If objBookNode.selectNodes("serviceResponse/ofsStandardEnquiry/enquiryColumn/enquiryrecord").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry").Attributes
             Debug.Print NodeValue
          End If
        Next objBookNode

    But after Service Response I am unable to get the values for Customer details...

      So It is very urgent  Please help me...

      I was unable to proceed
     
     Like How i want the Code as If i give the Node with enquiry column with cust id..I wanted to get the value of Cust id ...  
     

    <column>002100000415</column>

      So Please suggest me the Code how to read the values from 

    <ofsStandardEnquiry name="CUSTOMER-IBS" status="OK">

    <enquiryColumn globusType="STRING" id="CUST.ID" label="CUST.ID"/>

    <enquiryColumn globusType="STRING" id="FULL.NAME" label="FULL.NAME"/>

    <enquiryColumn globusType="STRING" id="USED.NAME" label="USED.NAME"/>

    <enquiryColumn globusType="STRING" id="DOB" label="DOB"/>

    <enquiryColumn globusType="STRING" id="OCCUPATION" label="OCCUPATION"/>

    <enquiryColumn globusType="STRING" id="NATIONALITY" label="NATIONALITY"/>

    <enquiryColumn globusType="STRING" id="ADDRESS" label="ADDRESS"/>

    <enquiryColumn globusType="STRING" id="WORK.PLACE" label="WORK.PLACE"/>

    <enquiryColumn globusType="STRING" id="GENDER" label="GENDER"/>

    <enquiryColumn globusType="STRING" id="COUNTRY.ID" label="COUNTRY.ID"/>

    <enquiryColumn globusType="STRING" id="MOBIL.NUM" label="MOBIL.NUM"/>

    <enquiryColumn globusType="STRING" id="HOME.TEL" label="HOME.TEL"/>

    <enquiryColumn globusType="STRING" id="OFFICE.TEL" label="OFFICE.TEL"/>

    <enquiryColumn globusType="STRING" id="FAX.NO" label="FAX.NO"/>

    <enquiryColumn globusType="STRING" id="EMAIL" label="EMAIL"/>

    <enquiryColumn globusType="STRING" id="ID.TYPE" label="ID.TYPE"/>

    <enquiryColumn globusType="STRING" id="ID.NUMBER" label="ID.NUMBER"/>

    <enquiryColumn globusType="STRING" id="ID.ISS.DATE" label="ID.ISS.DATE"/>

    <enquiryColumn globusType="STRING" id="ID.PLACE.ISS" label="ID.PLACE.ISS"/>

    <enquiryColumn globusType="STRING" id="TAX.CODE" label="TAX.CODE"/>

    <enquiryColumn globusType="STRING" id="CU.STATUS" label="CU.STATUS"/>

    <enquiryColumn globusType="STRING" id="SECTOR.NAME" label="SECTOR.NAME"/>

    <enquiryColumn globusType="STRING" id="BRANCH" label="BRANCH"/>

    <enquiryRecord>

    <column> 100297</column>

    <column>NGUYEN THI THANH VAN </column>

    <column>NGUYEN THI THANH VAN </column>

    <column>21 JUL 1980</column>

    <column> </column>

    <column>VN</column>

    <column>195 TRAN HUNG DAO-Q5-TP.HO CHI MINH </column>

    <column> </column><column> </column>

    <column>VIET NAM </column>

    <column> </column><column> </column>

    <column> </column><column> </column>

    <column> </column>

    <column>CMND </column><column>023456789 </column>

    <column>12 SEP 2000</column><column>TP HCM </column>

    <column> </column>

    <column>1-Private Client - Standard</column>

    <column>1001-IndividualCa nhan </column>

    <column>VN0010001 </column>

    </enquiryRecord>

    </ofsStandardEnquiry>

    and get them populated in my VB code and show in my frontend Screen..

     So Please suggest me immeditely  ...


    • Moved by Riquel_Dong Friday, March 6, 2009 4:51 AM (Moved from Visual Basic Express Edition to Off-Topic Posts (Do Not Post Here))
    • Moved by Riquel_Dong Friday, March 6, 2009 4:51 AM (Moved from Visual Basic Express Edition to Off-Topic Posts (Do Not Post Here))
    Wednesday, March 4, 2009 7:23 AM

Answers

  • This was moved out of the VB forum.

    You can ask this question in a different VB forum.

    Or I can move it to a specific VB forum if you'd like.

    This is regarding your code:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <Globus xmlns="http://www.temenos.com/GLOBUS/OFSML/120" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.temenos.com/GLOBUS/OFSML/120 ../../xsd/ofsml.xsd"><ofsmlHeader ofsmlMajor="2" ofsmlMinor="2" ofsmlRelease="1"><requestChannel>Browser.1</requestChannel>
    
    <company>VN0010001</company>
    
    <requestId>bc7ae08a836e226bA2018acfd11fb731d23aA7fff</requestId>
    
    <requestTimeStamp>2009-02-27T17:05:25</requestTimeStamp>
    
    <responseTimeStamp>2009-02-27T17:05:25</responseTimeStamp>
    
    </ofsmlHeader>
    
    
    

     


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Thursday, December 22, 2011 2:19 PM

All replies

  • For VB6 Questions, Please Read here.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, March 6, 2009 4:50 AM
  • thank u riquel.

    As i require th evalues from this enquiry record column So i have exatracted as below  

     If objBookNode.selectNodes("serviceResponse/ofsStandardEnquiry").length <> 0 Then
             NodeValue = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry").nodeTypedValue
             AccNo = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(0).nodeTypedValue
             Custid = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(1).nodeTypedValue
             custname = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(2).nodeTypedValue
             AcName = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(3).nodeTypedValue
             Actype = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(4).nodeTypedValue
             accurr = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(4).nodeTypedValue
             onactbal = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(6).nodeTypedValue
             WrBal = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(7).nodeTypedValue
             lmtamt = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(8).nodeTypedValue
             pstres = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(9).nodeTypedValue
             mnmbal = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(10).nodeTypedValue
             usdbal = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(11).nodeTypedValue
             lsttrandate = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(12).nodeTypedValue
             Accrin = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(13).nodeTypedValue
             Status = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(14).nodeTypedValue
             totcr = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(15).nodeTypedValue
             totdr = objBookNode.selectSingleNode("serviceResponse/ofsStandardEnquiry/enquiryRecord").childNodes(16).nodeTypedValue
             Debug.Print NodeValue


    I got the values correctly .. 

    So I have another work for writing the XML file from VB 6.0 

    I have to write the file as  

    <Globus xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance'

    xmlns = 'http://www.temenos.com/GLOBUS/OFSML/120'

    xsi:schemaLocation = 'http://www.temenos.com/GLOBUS/OFSML/120 ../../xsd/ofsml.xsd'>

    <ofsmlHeader xsi:nil="true" />

    <serviceRequest>

    <securityContext>

    <userName>INPUTT</userName>2222

    <password>123456</password>

    <company>VN0010001</company>

    </securityContext>

    <ofsStandardEnquiry name = 'ACCOUNT-IBS'>

    <selectionCriteria operand = "EQ">

    <fieldName>ACCOUNT.NUMBER</fieldName>

    <value>002100000415</value>

    </selectionCriteria>

    </ofsStandardEnquiry>

    </serviceRequest>

    </Globus>  


    So i have written as 
     

          Dim objDOM As New MSXML2.DOMDocument30
       Dim objnode As MSXML2.IXMLDOMNode
       Dim objChildNode As MSXML2.IXMLDOMNode
     
       Dim ObjServicereq As MSXML2.IXMLDOMNode
       Dim objserviceCon As MSXML2.IXMLDOMNode
       Dim ofsStandardEnquiry As MSXML2.IXMLDOMNode
       Dim objattribute As MSXML2.IXMLDOMAttribute
       Dim objattribute1 As MSXML2.IXMLDOMAttribute
       Dim objattribute2 As MSXML2.IXMLDOMAttribute
       Dim objelement As MSXML2.IXMLDOMElement
       Dim objelement1 As MSXML2.IXMLDOMElement
       Dim objattribute3 As MSXML2.IXMLDOMAttribute
       Dim objattribute4 As MSXML2.IXMLDOMAttribute
       Dim objattribute5 As MSXML2.IXMLDOMAttribute
     
    '   Set objNode = objDOM.createNode(NODE_PROCESSING_INSTRUCTION, "xml", "")
    '   objDOM.appendChild objNode
    '
     
     
       Set objnode = objDOM.createNode(NODE_ELEMENT, "GLOBUS", "")
        Set objelement = objnode
    '
       Set objattribute = objDOM.createAttribute("xmlns:xsi")
       objattribute.Text = "http://www.w3.org/2001/XMLSchema-instance"
       objelement.setAttributeNode objattribute
    '
         Set objattribute1 = objDOM.createAttribute("xmlns")
         objattribute1.Text = "http://www.temenos.com/GLOBUS/OFSML/120"
         objelement.setAttributeNode objattribute1

        Set objattribute2 = objDOM.createAttribute("xsi:schemaLocation")
        objattribute2.Text = "http://www.temenos.com/GLOBUS/OFSML/120 ../../xsd/ofsml.xsd"
        objelement.setAttributeNode objattribute2

    '
        
         Set objattribute = Nothing
         Set objattribute1 = Nothing
         Set objattribute2 = Nothing
      
       
         Set objChildNode = objDOM.createNode(NODE_ELEMENT, "ofsmlHeader", "")
         Set objattribute3 = objDOM.createAttribute("xsi:nil")
         objattribute3.Text = "true"
        
         Set objelement1 = objChildNode
         objnode.appendChild objChildNode
         objelement1.setAttributeNode objattribute3

         Set objelement1 = Nothing
         Set ObjServicereq = objDOM.createNode(NODE_ELEMENT, "serviceRequest", "")
         objChildNode.appendChild ObjServicereq
     
     
     
       Set objserviceCon = objDOM.createNode(NODE_ELEMENT, "securityContext", "")
      
         Dim xmlElmName As MSXML2.IXMLDOMElement
         Set xmlElmName = objDOM.createElement("userName")
         objserviceCon.appendChild xmlElmName
         xmlElmName.Text = "INPUTT"

     Dim xmlElmPASSWORD As MSXML2.IXMLDOMElement
    Set xmlElmPASSWORD = objDOM.createElement("password")
     objserviceCon.appendChild xmlElmPASSWORD
     xmlElmPASSWORD.Text = "123456"
     
     
     Dim xmlElmcompany As MSXML2.IXMLDOMElement
     Set xmlElmcompany = objDOM.createElement("company")
     objserviceCon.appendChild xmlElmcompany
      xmlElmcompany.Text = "VN0010001"
     
       objnode.appendChild ObjServicereq
       ObjServicereq.appendChild objserviceCon
       Set objserviceCon = Nothing
     
     
       Set ofsStandardEnquiry = objDOM.createNode(NODE_ELEMENT, "ofsStandardEnquiry", "")
           Set objattribute4 = objDOM.createAttribute("NAME")
       objattribute4.Text = "ACCOUNT-IBS"
       Set objelement = ofsStandardEnquiry
       objnode.appendChild ofsStandardEnquiry
       objelement.setAttributeNode objattribute4
          ObjServicereq.appendChild ofsStandardEnquiry
     
           Dim objselectioncriteria As MSXML2.IXMLDOMNode
            Set objselectioncriteria = objDOM.createNode(NODE_ELEMENT, "selectionCriteria", "")
            Set objattribute5 = objDOM.createAttribute("Operand")
           objattribute5.Text = "EQ"
            Set objelement = objselectioncriteria
            ObjServicereq.appendChild objselectioncriteria
            objelement.setAttributeNode objattribute5
            Set objelement = Nothing
           
           
           
             Dim xmlElmfieldName As MSXML2.IXMLDOMElement
            Set xmlElmfieldName = objDOM.createElement("fieldName")
            objselectioncriteria.appendChild xmlElmfieldName
            xmlElmfieldName.Text = "CUSTOMER.CODE"
     
     
     Dim xmlElmvalue As MSXML2.IXMLDOMElement
     Set xmlElmvalue = objDOM.createElement("value")
     objselectioncriteria.appendChild xmlElmvalue
      xmlElmvalue.Text = "100297"

       objnode.appendChild ObjServicereq
       objDOM.appendChild objnode
       Set objelement = Nothing
        Set objChildNode = Nothing
        Set objselectioncriteria = Nothing
        Set ofsStandardEnquiry = Nothing
        Set ObjServicereq = Nothing
       Set objnode = Nothing
     
       MsgBox objDOM.xml
       objDOM.save ("C:\SCBDATA\Request\Request_ACC.XML")
       Debug.Print objDOM.xml
       Set objDOM = Nothing
      ' Call GENCUST
    End Sub  

    but i get output as  

      

    <Globus xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance'

    xmlns = 'http://www.temenos.com/GLOBUS/OFSML/120'

    xsi:schemaLocation = 'http://www.temenos.com/GLOBUS/OFSML/120 ../../xsd/ofsml.xsd'>

    <ofsmlHeader xmlns = "" xsi:nil="true" />

    <serviceRequest xmlns = "" >

    <securityContext>

    <userName>INPUTT</userName>2222

    <password>123456</password>

    <company>VN0010001</company>

    </securityContext>

    <ofsStandardEnquiry name = 'ACCOUNT-IBS'>

    <selectionCriteria operand = "EQ">

    <fieldName>ACCOUNT.NUMBER</fieldName>

    <value>002100000415</value>

    </selectionCriteria>

    </ofsStandardEnquiry>

    </serviceRequest>

    </Globus>  


    xmlns = ""   is repeting at ofsmlheaser and service request ,.. please help me like how to write it by getting it correctly ... 

    Friday, May 1, 2009 10:15 AM
  • This was moved out of the VB forum.

    You can ask this question in a different VB forum.

    Or I can move it to a specific VB forum if you'd like.

    This is regarding your code:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <Globus xmlns="http://www.temenos.com/GLOBUS/OFSML/120" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.temenos.com/GLOBUS/OFSML/120 ../../xsd/ofsml.xsd"><ofsmlHeader ofsmlMajor="2" ofsmlMinor="2" ofsmlRelease="1"><requestChannel>Browser.1</requestChannel>
    
    <company>VN0010001</company>
    
    <requestId>bc7ae08a836e226bA2018acfd11fb731d23aA7fff</requestId>
    
    <requestTimeStamp>2009-02-27T17:05:25</requestTimeStamp>
    
    <responseTimeStamp>2009-02-27T17:05:25</responseTimeStamp>
    
    </ofsmlHeader>
    
    
    

     


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Thursday, December 22, 2011 2:19 PM