Page 1 of 3 123 LastLast
Results 1 to 5 of 11

Thread: Read/Write XML files from IS script

  1. #1
    suniltg Guest

    Question Read/Write XML files from IS script

    Hi All,

    I want to know whether there is a way to Read/Write XML files from InsallShield script. Normal file methods won't do. i.e., Is there some xml reading/manipulating functions in InsallShield 7.03?

    Thanks in advance,
    Sunil

  2. #2
    Join Date
    Oct 2001
    Location
    Here and there
    Posts
    16,243
    Alas, there's nothing currently built-in; you can cast a vote at: http://www.installshield.com/feedbac...s/feedback.asp.

  3. #3
    cibbeson Guest
    This is just a shot in the dark suggestion that I have not tried, so take it for what it's worth...

    Since InstallScript now supports COM objects, can't you load the XMLDOM (I forgot exactly what it's called) object and call it's methods to read/parse an XML file?

    I'll probably get corrected by Robert, but I figured it was worth a shot!

  4. #4
    Join Date
    Oct 2001
    Location
    Here and there
    Posts
    16,243
    I'm a lousy XML programmer, but as proof of concept this seems to work:
    Code:
    function OnBegin( )
        OBJECT oDoc, speech_list;
        INT i;
    begin
    
    set oDoc = CoCreateObject("MSXML.DOMDocument");
    
    if oDoc.Load("C:\\xml\\hamlet.xml") then
        set speech_list = oDoc.getElementsByTagName("SPEECH");
    
        for i = 0 to (speech_list.Length - 1)
            MessageBox(speech_list.Item(i).text, INFORMATION);
        endfor;
    else
        // HAMLET: O, fie!
    endif;
    
    set oDoc = NOTHING;
    The down side, of course, is that the XML parser has to be on the target system...
    Last edited by RobertDickau; 08-27-2006 at 08:21 AM. Reason: all these years later, updated to use CoCreateObject instead of CreateObject

  5. #5
    Join Date
    Jan 2003
    Location
    Michigan, USA
    Posts
    180
    I am able to read from a XML file using the following methods.
    But, i am unable to write back to the XML file or make changes from my script. (The XML file is already present in the machine)
    Code:
    OBJECT oDoc;
    variant root, newNode, nodeInfo, myErr, ndEZ, list;
    variant comment;
    -------
    -------	
    
    set oDoc = CreateObject("MSXML.DOMDocument"); 
    oDoc.Load("D:\\Docs\\XML\\TechXML.xml");
    
    if (oDoc.parseError.errorCode != 0) then
          myErr = oDoc.parseError;
          MessageBox(myErr, INFORMATION);
    else   		
          root = oDoc.documentElement;
          ndEZ = oDoc.createTextNode("HelloWorld");
          root.childNodes.item(0).appendChild(ndEZ);
          root.childNodes.item(0).lastChild.text = "123";
          MessageBox(ndEZ.text, INFORMATION);            //output is "123"
          comment = oDoc.createComment("Hello World!");
          comment.insertData(6, "Beautiful ");
    endif;
    The code is called from OnBegin method
    (I apologise for cross posting- i am using IS Professional 7)
    Last edited by vinodn1; 06-11-2004 at 12:55 PM.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •