Open and parse file XML
Posted 01 April 2003 - 08:43
Have you ever do it ?
Posted 01 April 2003 - 19:11
Here is a sample IS code that I used to read the data section of an XML file. It relies on the fact that the XML file is a text-based file. I seek the name of the field and store the string value in a global list to use elsewhere. In the example below, I am looking for a string “CompanyID=” and the value is 11 characters greater than the starting position of the string “CompanyID=”. Maybe it can help you develop your own code.
// Define this list Globally to read contents in other functions
// Function: ReadXML()
STRING svResult , svLine, svSubLine;
NUMBER nResult, nvFileHandle, nStartPosition, nEndPosition, nLastPosition;
//// CompanyID= ////////////////////////////////////////////////
TARGETDIR = "C:\\MyFolder";
ChangeDirectory ( TARGETDIR );
nResult = FindFile ( TARGETDIR , "MyFile.xml" , svResult );
if nResult = 0 then
OpenFileMode ( FILE_MODE_NORMAL );
OpenFile ( nvFileHandle , TARGETDIR , "MyFile.xml" );
GetLine ( nvFileHandle , svLine );
CloseFile ( nvFileHandle );
nLastPosition = StrLength(svLine);
if nLastPosition > 0 then
list_Company_Paths = ListCreate ( STRINGLIST );
while nLastPosition > 0
// read the string svLine
// MessageBox ( svLine , INFORMATION );
nStartPosition = StrFind ( svLine , "CompanyID=" );
if nStartPosition > 0 then // found it
nStartPosition = nStartPosition + 11; // data starts offset
StrSub ( svSubLine , svLine , nStartPosition , nLastPosition );
nEndPosition = StrFind ( svSubLine , "\"" );
StrSub ( svResult , svLine , nStartPosition , nEndPosition );
//MessageBox ( svResult , INFORMATION ); //For testing
ListAddString ( list_Company_Paths , TARGETDIR ^ svResult , AFTER );
svLine = svSubLine;
nLastPosition = 0;
Posted 02 April 2003 - 09:55
but my file is more complex. i have some big tree and
I can't use some tag.
I think it needs to use MSXML but it wasn't so simple
Posted 03 April 2003 - 14:28
do you use "UseDll( msxml2.dll )" in the script an prototyp the functions like "selectSingleNode" ...?
Just like using WINAPI functions?
Posted 03 April 2003 - 15:21
after looking into the dll, it just exports the functions
Unlike user32.dll or kernel32.dll (which can be loaded and used for WINAPI calls like "GetDiskFreeSpaceA") msxml* dlls do not export the functions that could be used for creating DOM Documents and parsing and ...
Maybe it could be done with VisualBasic.
Search for XML on the forum, it has been discussed several times how to parse and write XML files, but no real answeres I could see.
Maybe you could write a personal message or email to the folks that looked for a solution?
Posted 03 April 2003 - 16:38
Posted 04 April 2003 - 15:54
Posted 04 April 2003 - 17:23
In using msxml we don't reinvent the wheel
but the interface wasn't so easy
May be installshield could be develop this object
Posted 05 April 2003 - 00:55
XML is certainly growing in popularity and general usage (just look at Office 2003). I'm sure InstallShield will have to add built-in support for XML at some point much like it does for INIs now.
I'm not sure if IS Professional 7 has it, probably not, but I thinking IS Developer 8 might.
Posted 08 April 2003 - 14:26
There may be a way to wrap the msxml methods in IS rules ...
InstallShield will do anything but add XML support to IS 5.x (oops, but also for IS 6.x I suppose)