Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting values from an XML File
Message
From
15/10/2006 07:56:48
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Title:
Getting values from an XML File
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01162072
Message ID:
01162072
Views:
63
Hi,

I've got this XML file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="MistRep.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="MistRep.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <connectionStrings>
        <add name="MistRep.My.MySettings.mist2006ConnectionString" connectionString="Data Source=samaan6;Initial Catalog=mist2006;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.diagnostics>
        <sources>
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
        </sharedListeners>
    </system.diagnostics>
    <applicationSettings>
        <MistRep.My.MySettings>
            <setting name="TestMe_ReportService2005_ReportingService2005"
                serializeAs="String">
                <value>http://samaan6/ReportServer/ReportService2005.asmx</value>
            </setting>
            <setting name="MySampleProp" serializeAs="String">
                <value>This is my Property Value</value>
            </setting>
            <setting name="MistReportFolder" serializeAs="String">
                <value>/Mist Report 2006</value>
            </setting>
            <setting name="ReportsUrl" serializeAs="String">
                <value>http://samaan6/ReportServer</value>
            </setting>
        </MistRep.My.MySettings>
    </applicationSettings>
    <userSettings>
        <MistRep.My.MySettings>
            <setting name="MistDataEntry" serializeAs="String">
                <value>c:\program files\mist2006\mist2006.exe</value>
            </setting>
        </MistRep.My.MySettings>
    </userSettings>
</configuration>
I want to be able to get some of the values out of this file, change them and write them back.

I tried:
LOCAL loXMLAdapter as XMLAdapter
m.loXMLAdapter = NEWOBJECT('XMLAdapter')
WITH m.loXMLAdapter
	.LoadXML(<filename and path>, .T.)

	FOR I = 1 TO .Tables.Count
	   oXMLTable = .Tables.Item(I)
	   ? oXMLTable.Alias
	ENDFOR
ENDWITH 
but tables.count is 0.

Is there an easier way to do this than bringing the file into a string and parsing it using ALINES(), changing the values I want and recreating the file?

Thanks.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform