This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- reading XML Values
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
โJan 17, 2008
05:50 AM
reading XML Values
Hi,
Can we read XML files through inbuilt functions in IS. I am using install script projects. Currently i am reading XML as a text file line by line. And then i am removing the <> tags.
Please help me.
Thanks in advance,
Chandrakant
Can we read XML files through inbuilt functions in IS. I am using install script projects. Currently i am reading XML as a text file line by line. And then i am removing the <> tags.
Please help me.
Thanks in advance,
Chandrakant
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
โJan 21, 2008
10:50 AM
Hello,
Here is something you can try. The code below will allow you to read and modify a XML encoded file. Have fun... ๐
Here is something you can try. The code below will allow you to read and modify a XML encoded file. Have fun... ๐
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
prototype ModifyWebConfig(BYVAL STRING, BYREF STRING);
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function ModifyWebConfig(strFileName, strError)
OBJECT oDoc, oNode, oNodeList;
NUMBER i, nSize;
STRING strNamedItem;
STRING strValue;
begin
///////////////////////////////////////////////////////////////////////////
// Check to see if the file exists...
///////////////////////////////////////////////////////////////////////////
if Is(FILE_EXISTS, strFileName) = TRUE then
//MessageBox("XML file exists",0);
else
MessageBox("XML file is missing",0);
endif;
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
nSize = 300;
i = 0;
//Data Source=MySQLServer;Initial Catalog=MyDatabase;Persist Security Info=True;User ID=MyUserName;Password=MyPassword
strValue = "Data Source=" + m_strDBDataSource;
strValue = strValue +";User Id=" + m_strDBUserName;
strValue = strValue +";Password=" + m_strDBPassword;
strValue = strValue +";Initial Catalog="+ m_strDBName;
strValue = strValue +";Persist Security Info=True";
///////////////////////////////////////////////////////////////////////////
// get values from public properties
///////////////////////////////////////////////////////////////////////////
set oDoc = CreateObject("Msxml2.DOMDocument.4.0");
if (IsObject(oDoc) = FALSE) then
MessageBox(ERROR_XML_FILE_CREATION, 0);
return -1;
endif;
oDoc.async = FALSE;
oDoc.setProperty("SelectionLanguage", "XPath");
///////////////////////////////////////////////////////////////////////////
// if success, traverse file and substitute value //
///////////////////////////////////////////////////////////////////////////
if oDoc.load(strFileName) then
///////////////////////////////////////////////////////////////////////
// get list of matching nodes //
///////////////////////////////////////////////////////////////////////
set oNodeList = oDoc.getElementsByTagName("*");
if (oNodeList.length > 0) then
for i = 0 to (oNodeList.length - 1);
set oNode = oNodeList.nextNode;
try
strNamedItem = oNode.attributes.getNamedItem("key").value;
catch
strNamedItem = "";
endcatch;
try
if strNamedItem = "SQLConnection" then
oNode.attributes.getNamedItem("value").value = strValue;
//elseif strNamedItem = "ProductVersion" then
// oNode.attributes.getNamedItem("value").value = IFX_PRODUCT_VERSION;
endif;
catch
endcatch;
endfor;
else
MessageBox(ERROR_XML_FILE_STRUCTURE,SEVERE);
return -1;
endif;
else
MessageBox(ERROR_XML_FILE_LOAD,SEVERE);
return -1;
endif;
oDoc.save(strFileName);
set oDoc = NOTHING;
end;