PDA

View Full Version : Looking into the XML part of things


ianhull
02-21-2007, 04:09 PM
Hi Guys,

I am looking into using xml in a project but I am totally confused and I have not used AMS for aaaaages.

Heres what I have



XML.Load("C:\\MyFile.xml");
fname = XML.GetValue("database/customer id/first_name");






How do I get fname into a list box?

Thanks

yosik
02-21-2007, 04:19 PM
Hi,
As fname is a string, you can use the ListBox.SetItemData (or SetItemText) action:
ListBox.SetItemData ("yourListBox",1,fname);

Yossi

ianhull
02-21-2007, 04:20 PM
Yossi :)

Thanks

ianhull
02-21-2007, 04:28 PM
mmm, does not seem to work for me,

I am using the examples from the help manual too.

I have also read about a little bug relating to a trailing slash, I tried that but still nothing.

any ideas?

On Preload:


XML.Load("C:\\MyFile.xml");
fname = XML.GetValue("*/customer");




On Show:


ListBox.SetItemData("yourListBox",1,fname);
ListBox.SetItemText("yourListBox",1,fname);

yosik
02-21-2007, 04:31 PM
Try and debug it and see what is the actual value for fname

ianhull
02-21-2007, 04:43 PM
Hi yosik,

Is there an internal debugger? I cannot find it anywhere

thanks

TJ_Tigger
02-21-2007, 04:45 PM
I use Dialog.Message("Testing", fname) to test values all the time. Throw that in there to see what is returned. Might be that nothing is found at the path/value you specified and it returns nil or a blank string. Cant remember right now which one it is.

Tigg

TJ_Tigger
02-21-2007, 04:46 PM
Hi yosik,

Is there an internal debugger? I cannot find it anywhere

thanks

Edit -> Preferences : [] Show Debug window

Tigg

ianhull
02-21-2007, 05:01 PM
Debug Output




*** LOCATION: Page1 -> On Mouse Move
[1]: XML.Load("C:\\MyFile.xml");
TRACE: LastError = 0 ("Success.")
[2]: fname = XML.GetValue("*/customer");
TRACE: LastError = 0 ("Success.")
[3]: ListBox.SetItemData("yourListBox",1,fname);
TRACE: LastError = 1702 ("Index out of range")
[4]: ListBox.SetItemText("yourListBox",1,fname);
TRACE: LastError = 1702 ("Index out of range")

TJ_Tigger
02-21-2007, 05:26 PM
Try ListBox.AddItem. I believe the SetItemText and SetItemData is for an item that already exists in the listbox.

Tigg

ianhull
02-21-2007, 05:37 PM
ListBox.AddItem("yourListBox",fname);

This works great,

thanks again guys

much appreciated.