Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Component and Bind with XML

Status
Not open for further replies.

fireburner69

Programmer
Aug 22, 2002
108
GR
I have a XML with this structure:

<?xml version="1.0" encoding="UTF-8"?>
<cats>
<cat name="catname">
<cat_id>1</cat_id>
</cat>
<cats>


I add a list component and I want to pass the name as the title and the cat_id as the data! So when a user select the cat the data will be the id of the cat?

The way I am doing it in the list I have something like catname,1
Is there any way to make this?

Note: I use also XMLconnector in order to parse the XML.
So the binding I am doing is very simple!

Any ideas?
 
First thing you should do is fix your XML. It will just give you trouble like that. You've mixed methods....

Code:
<?xml version="1.0" encoding="UTF-8"?>
<cats>
    <cat name="catname" id=1></cat>
<cats>

or

Code:
<?xml version="1.0" encoding="UTF-8"?>
<cats>
    <cat>
        <cat_name="catname">
        <cat_id>1</cat_id>
    </cat>
<cats>

After you have loaded the XML into a dataset you can add the data to the list from the dataset.

Code:
listName.addItem({label:datasetName.currentItem.cat_name, data:datasetName.currentItem.cat_id});

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
So you are saying to add a DataSet component and after that to parse them into the list?
right?

Is there another way to bind the List component with the xml so that this can be made without the dataset comp?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top