SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    Feb 2003
    Posts
    533
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Reading thru XML file

    I have XML document from which I need to fetch info. Below is the structure. Account header aggregate is for every account number. I am new to VBscript and also to QTP. So can anyone of you experts please tell the syntax to loop thru the XML file for each account and fetch specfied node value for that account.
    <accountHeader>
    <fiAddress />
    <accountNumber>1</accountNumber>
    <startDate>20070102</startDate>
    <endDate>20070102</endDate>
    <memberBranchCode>2</memberBranchCode>
    <memberName>LEE MERCER</memberName>
    <addressLine1>1 ARLINGTON DRIVE</addressLine1>
    <cityStateZip>UPPER DARBY PA 19000</cityStateZip>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    <statementMessage>Message for 8 lines per inch</statementMessage>
    </accountHeader>

  2. #2
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Reading thru XML file

    Search for XMLUtil on the forum and try to experiment a bit.

  3. #3
    Senior Member
    Join Date
    Feb 2003
    Posts
    533
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Reading thru XML file

    Already Did.....Right now I am trying to figure why below.
    The XML source is not well formed: The XML declaration is unexpected. Line 1, position 4.
    Parameter name: XML source
    Line (10): "doc.LoadFile "C:\QTPScripts\Statement_XML\stmt.xml"".

    here is my code.

    Set doc = XMLUtil.CreateXML()
    doc.LoadFile "C:\QTPScripts\Statement_XML\stmt.xml"

    Set root = doc.GetRootElement()
    Set children = root.ChildElements()
    Set child = children.ItemByName("accountHeader")
    msgbox child
    numOfChildren = 0

    While Not child Is nothing
    numOfChildren = numOfChildren+1
    Set child = children.ItemByName("accountheader",numOfChildren+ 1)
    msgbox child
    Wend

    msgbox "The number of children named accountHeader is " & numOfChildren
    Set Doc=Nothing

  4. #4
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Reading thru XML file

    From where are you getting the XML File?

  5. #5
    Senior Member
    Join Date
    Feb 2003
    Posts
    533
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Reading thru XML file

    [ QUOTE ]
    From where are you getting the XML File?

    [/ QUOTE ]
    I got rid of the error. It was something in the source file. Right now I am having issue on msgbox statement. When script is run I am getting object variable not set.

    Set child = children.ItemByName("accountHeader")
    msgbox child

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.50%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:54 PM.

Copyright BetaSoft Inc.