SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Jan 2009
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Object required: \'xmlDoc.SelectSinglenode(...)\'

    Hi,

    I have written following code toedit and save xml file. But i am getting a warning message saying "Object required: 'xmlDoc.SelectSinglenode(...)'" at following line: "xmlDoc.selectSingleNode("ABCD/Stat/EtId").text = "00299""

    //code
    Dim sourceFileName, destinationFileName, xmlDoc, date, dateStr

    sourceFileName = "c:\\Test.xml"
    destinationFileName = "c:\\Test_new.xml"

    Set xmlDoc = Sys.OleObject("Msxml2.DOMDocument")
    If Not xmlDoc.load(sourceFileName) Then
    Log.Error("An error occurred when loading the " & sourceFileName & " XML file")
    Exit Sub
    End If
    xmlDoc.selectSingleNode("ABCD/Stat/EtId").text = "00299"
    date = aqDateTime.Now()
    dateStr = aqConvert.DateTimeToFormatStr(date, "%Y-%m-%d")
    xmlDoc.selectSingleNode("ABCD/Stat/BDate").text = dateStr

    xmlDoc.save(destinationFileName)
    //code

    Can any one please tell me what am i doing wrong? Its very [stupid is as stupid does] please.

  2. #2
    Moderator tristaanogre's Avatar
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA
    Posts
    1,792
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Object required: \'xmlDoc.SelectSinglenode(...)\'

    Is it possible that selectSingleNode is returning an empty set? One thing you don't have is a check to see if selectSingleNode actually returned something. That would be my first place to check.
    -Robert Martin
    Automated Testing Evangelists
    TestComplete "expert"
    Definition expert - noun - Unknown drip under pressure

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

    Re: Object required: \'xmlDoc.SelectSinglenode(...)\'

    Hello Abhayb,

    You need to make sure that the "ABCD/Stat/EtId" nodes sequence exists in your file ("c:\\Test.xml"). For example, for your script to work correctly, you need to have the following text in your file:

    <font class="small">Code:</font><hr /><pre>
    &lt;ABCD&gt;
    &lt;Stat&gt;
    &lt;EtId&gt;00299&lt;EtId&gt;
    &lt;Stat&gt;
    &lt;ABCD&gt;
    </pre><hr />

    Also, note that nodes' names are case-sensitive. For example, "ABCD" and "abcd" are different nodes.
    Regards,
    Alex - SmartBear Support

 

 

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 10.71%
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 06:24 AM.

Copyright BetaSoft Inc.