PDA

View Full Version : XML.SetValue Path


AXXESS
09-01-2005, 01:36 PM
I am attempting to use XML.SetValue to change the value of "Assistance" from "true" to "false", thus toggling the radio button in its group.

When referencing the path, does the full path have to be referenced? I.E., AutoPlay\\Docs\\...? Then, based on the example, what is the proper path to change the value?

After changing the value, is the XML.Save action required, or is the change written and saved to the XML file with the SetValue action?


<?xml version="1.0" encoding="iso-8859-1" ?>
- <menu lang="en">
- <item label="File">
<item label="Exit" />
</item>
- <item label="Documents">
- <item label="Instructions">
<item label="Standard Buttons" />
<item label="Address Bar" />
<item label="Links" />
<item type="separator" />
<item label="Lock the Toolbars" />
</item>
- <item label="Specifications">
<item label="Standard Buttons" />
<item label="Address Bar" />
<item label="Links" />
<item type="separator" />
<item label="Lock the Toolbars" />
</item>
- <item label="References">
<item label="Standard Buttons" />
<item label="Address Bar" />
<item label="Links" />
<item type="separator" />
<item label="Lock the Toolbars" />
</item>
</item>
- <item label="Instruction">
- <item label="Overview">
<item label="Standard Buttons" type="check" selected="true" />
<item label="Address Bar" type="check" selected="true" />
<item label="Links" type="check" selected="true" />
<item type="separator" />
<item label="Lock the Toolbars" type="check" selected="true" />
<item label="Customize…" />
</item>
<item label="Type 1" />
- <item label="Type 2">
<item label="Search" type="check" />
<item label="Favorites" type="check" />
<item label="Media" type="check" />
<item label="History" type="check" />
<item label="Folders" type="check" />
</item>
</item>
- <item label="Options">
- <item label="Assistance">
<item label="On" type="radio" groupName="assistance" selected="true" />
<item label="Off" type="radio" groupName="assistance" selected="false" />
</item>
<item type="separator" />
- <item label="Narration">
<item label="On" type="radio" groupName="narration" selected="true" />
<item label="Off" type="radio" groupName="narration" selected="false" />
</item>
</item>
- <item label="Help">
<item label="Contents and Index" />
<item type="separator" />
<item label="Check for Update" />
<item type="separator" />
<item label="About…" />
<item label="Program Support" />
</item>
</menu>

TJ_Tigger
09-01-2005, 02:33 PM
The full path needs to be referenced within the XML, not the PC's directory structure and the items contained within the <> will be attributes so you will want to XML.SetAttribute. For instance;

XML.SetAttribute("menu/item:4/item:1/item:1", "selected", "false");
XML.SetAttribute("menu/item:4/item:1/item:2", "selected", "true");

The above is based on the file you posted, since all the strings are labled item, you have to specify which item number you want to modify. So the above will set item 4, item 1 and then item 1 to false and then item 4, item1, item 2 to true. I have created a tabed version posted below


<?xml version="1.0" encoding="iso-8859-1" ?>
- <menu lang="en">
- <item label="File">
<item label="Exit" />
</item>
- <item label="Documents">
- <item label="Instructions">
<item label="Standard Buttons" />
<item label="Address Bar" />
<item label="Links" />
<item type="separator" />
<item label="Lock the Toolbars" />
</item>
- <item label="Specifications">
<item label="Standard Buttons" />
<item label="Address Bar" />
<item label="Links" />
<item type="separator" />
<item label="Lock the Toolbars" />
</item>
- <item label="References">
<item label="Standard Buttons" />
<item label="Address Bar" />
<item label="Links" />
<item type="separator" />
<item label="Lock the Toolbars" />
</item>
</item>
- <item label="Instruction">
- <item label="Overview">
<item label="Standard Buttons" type="check" selected="true" />
<item label="Address Bar" type="check" selected="true" />
<item label="Links" type="check" selected="true" />
<item type="separator" />
<item label="Lock the Toolbars" type="check" selected="true" />
<item label="Customize…" />
</item>
<item label="Type 1" />
- <item label="Type 2">
<item label="Search" type="check" />
<item label="Favorites" type="check" />
<item label="Media" type="check" />
<item label="History" type="check" />
<item label="Folders" type="check" />
</item>
</item>
- <item label="Options"> menu/item:4
- <item label="Assistance"> menu/item:4/item:1
<item label="On" type="radio" groupName="assistance" selected="true" /> menu/item:4/item:1/item:1
<item label="Off" type="radio" groupName="assistance" selected="false" /> menu/item:4/item:1/item:2
</item>
<item type="separator" />
- <item label="Narration">
<item label="On" type="radio" groupName="narration" selected="true" />
<item label="Off" type="radio" groupName="narration" selected="false" />
</item>
</item>
- <item label="Help">
<item label="Contents and Index" />
<item type="separator" />
<item label="Check for Update" />
<item type="separator" />
<item label="About…" />
<item label="Program Support" />
</item>
</menu>



And you will have to do a XML.Save to write the XML information back to a file. The changes you made above were made in memory.

Tigg

AXXESS
09-01-2005, 02:56 PM
Good call, Tigg! :yes I was goofing around with both SetAttribute and SetValue for a couple hours... thanks for the help! :)

TJ_Tigger
09-01-2005, 03:32 PM
np glad it helped