0

I'm trying to read values from demo.xml file using innosetup and want to populate some sting values.Here is my demo.xml file

<?xml version="1.0" encoding="ISO-8859-1"?>
<context>
<object name="sapconfig" class="com.iqc.egl.common.content.sap.SapConfig">
    <string value=""/>
    <string value="saplabs;usa"/>
    <string value="uae"/>
    <string value="002"/>   
</object>

Here i want output populated as: saplabs;usa and uae .Can anybody guide me.Your help will be appreciated.This xml is static.

khanam
  • 335
  • 1
  • 4
  • 19
  • There is no way to distinguish between those attributes. All of them are `value` attributes of the `` tag. The only way to extract only those inner two is picking them by index. But once the XML changes and those nodes gets shuffled, you'll get different values. Are you sure this is what you want ? – TLama Aug 19 '15 at 11:32
  • @TLama,This xml will remains same. – khanam Aug 19 '15 at 11:34
  • @TLama,can you tell me How to read values based on index. – khanam Aug 19 '15 at 11:49
  • 1
    This [something like this](http://pastebin.com/603b9dFR). – TLama Aug 20 '15 at 15:13
  • @TLama,Thanks a lot.Your link is awesome.Its working fine. – khanam Sep 08 '15 at 06:05

1 Answers1

0

Create an instance of Msxml2.DOMDocument to access the xml file like explained here How to read and write XML document node values?

You can iterate over the childnodes using get_childNodes (https://msdn.microsoft.com/en-us/library/windows/desktop/dd873811%28v=vs.85%29.aspx) and use get_attribute (https://msdn.microsoft.com/en-us/library/windows/desktop/dd873626%28v=vs.85%29.aspx') to read "value".

Community
  • 1
  • 1
Wosi
  • 41,986
  • 17
  • 75
  • 82
  • Wosi,I'm unable to understand those links due to those example are in c++ – khanam Aug 19 '15 at 12:36
  • Here are some snippets about how to do work with MSXML using Delphi: http://www.gerixsoft.com/blog/delphi/msxml In Pascal Script it looks almost the same except that you are using `Variant` instead of `IXMLDOMNode` and `IXMLDOMNodeList`. – Wosi Aug 19 '15 at 12:44
  • Wosi,is innosetup and Delphi both same? – khanam Aug 19 '15 at 12:46
  • OKie,i will try,can i use variant instead of IXMLDOMNODe,IXMLDOMNodeList?. – khanam Aug 19 '15 at 12:47
  • 1
    Yes, you can. `Variant` is a datatype for general purpose. It's made for _everything_: http://www.delphibasics.co.uk/RTL.asp?Name=Variant – Wosi Aug 19 '15 at 12:51