mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 XML load Failure

Author Message
nattu_82

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 12/29/2009
  • Status: offline
XML load Failure Tuesday, December 29, 2009 7:18 PM (permalink)
0
I am unable to load an XML file in a tool called QTP which uses VB script.  Code used is below
const  XMLDataFile = "C:\Working\b2b\Amend\ELTMETRO381-CorrectDeal.xml"
const  XMLNewFile = "C:\Working\b2b\Amend\SNLTMETRO381-CorrectDeal.xml"
Set  xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async=false
rc = xmlDoc.load (XMLDataFile )
msgbox rc
 
not sure what the problem is as the variable rc always returns false. The source XML file is exactly in the same location.
following is abrief content of the XML
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE PSRequest>
<PSRequest>
<login>
<USER>sanatara</USER>
<APPNAME>PL</APPNAME>
</login>
<deal>
<ACTION>UPDATE</ACTION>
<DM_UPDATEUSER>sanatara</DM_UPDATEUSER>
 
 
#1
    ehvbs

    • Total Posts : 3312
    • Scores: 110
    • Reward points : 0
    • Joined: 6/22/2005
    • Location: Germany
    • Status: offline
    Re:XML load Failure Wednesday, December 30, 2009 4:46 AM (permalink)
    0
    (1) the XML you posted is bad

    (2) your .xml file is probably bad too

    (3) according to

          http://social.msdn.micros...47de-9840-c66af68d6c85
          http://msdn.microsoft.com...y/ms757837(VS.85).aspx

         you shouldn't use the ancient XMLDOM but the best/newest
         version of DomDocument

    (4) You should check the .parseError, if the .load fails

    All this in code

       Dim aXmlFSpecs : aXmlFSpecs = Array( _
           "M:\lib\kurs0705\testdata\xml\nattu\nattu-org-bad.xml" _
         , "M:\lib\kurs0705\testdata\xml\nattu\nattu-simple.xml" _
         , "M:\lib\kurs0705\testdata\xml\nattu\nattu-wdtd.xml" _
       )
       Dim aClsIds    : aClsIds    = Array( _
           "Microsoft.XMLDOM" _
         , "Msxml2.DOMDocument" _
       )
       Dim sFSpec, sClsId
       For Each sFSpec In aXmlFSpecs
           For Each sClsId In aClsIds
               WScript.Echo "using", sClsId, "to read", sFSpec
               Dim oXDoc : Set oXDoc = CreateObject( sClsId )
               oXDoc.async = False
               Dim bOk : bOk = oXDoc.load( sFSpec )
               If bOk Then
                  WScript.Echo "looks ok:", oXDoc.documentElement.tagName
               Else
                  WScript.Echo "Bingo:", oXDoc.parseError.reason
               End If
           Next
       Next
     


    output:

     loadXML00 - load an .xml doc (nattu)
     -------------------------------------------------------------------------------
     using Microsoft.XMLDOM to read M:\lib\kurs0705\testdata\xml\nattu\nattu-org-bad.xml
     Bingo: The element 'PSRequest' is used but not declared in the DTD/Schema.
     
     using Msxml2.DOMDocument to read M:\lib\kurs0705\testdata\xml\nattu\nattu-org-bad.xml
     Bingo: The element 'PSRequest' is used but not declared in the DTD/Schema.
     
     using Microsoft.XMLDOM to read M:\lib\kurs0705\testdata\xml\nattu\nattu-simple.xml
     looks ok: PSRequest
     using Msxml2.DOMDocument to read M:\lib\kurs0705\testdata\xml\nattu\nattu-simple.xml
     looks ok: PSRequest
     using Microsoft.XMLDOM to read M:\lib\kurs0705\testdata\xml\nattu\nattu-wdtd.xml
     looks ok: note
     using Msxml2.DOMDocument to read M:\lib\kurs0705\testdata\xml\nattu\nattu-wdtd.xml
     looks ok: note
     ===============================================================================
     xplxml.vbs: Erfolgreich beendet. (0) [ 0.12891 secs ]
     


    I got the nattu-wdtd.xml from www.w3schools.com:

     <?xml version="1.0" encoding="iso-8859-1" ?>
     <!-- http://www.w3schools.com/DTD/dtd_intro.asp -->
     <!DOCTYPE note [
     <!ELEMENT note (to,from,heading,body)>
     <!ELEMENT to (#PCDATA)>
     <!ELEMENT from (#PCDATA)>
     <!ELEMENT heading (#PCDATA)>
     <!ELEMENT body (#PCDATA)>
     ]>
     <note>
     <to>Tove</to>
     <from>Jani</from>
     <heading>Reminder</heading>
     <body>Don't forget me this weekend</body>
     </note>
     





    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.8
      mbt shoes www.wileywilson.com