Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Load XML file info into Combo Box

Avatar

Former Community Member
Hi,

I have a Combo box, and I have a XML Files and it XMLSchema



The Info of XML File is of City's I need load the city list into Combo Box



Who is that?



Who asociate the XMLSchema of city's with ComboBox?



Thanks all
6 Replies

Avatar

Former Community Member
One way to do it would be to set the binding to a string that represents the location of the City in the data... for example, in the Binding tab of the Drop Down List, if your XML looked like this:


New Brunswick
San Diego
Yellowknife


You could use this as the Default Binding:

$record.cities.city

That would populate the list with those three cities.
--
SteveX
Adobe Systems

Avatar

Former Community Member
Ah I'm sorry, I misspoke - the example I gave will just put the first child of <cities> into the drop-down list.<br /><br />There is actually a drop-down list in the Custom tab of the Library (called "Data Drop-down List") that supports populating the list from a data source; drop one of those on your form, and then take a look at the script associated with the object's initialize event. There are a few variables near the top that you need to update and then the list will populate from data.<br />--<br />SteveX<br />Adobe Systems

Avatar

Former Community Member
Given that your city data is in an XML file, the data drop down list won't actually help you. And it turns out, the example of the <cities> node above with each city having its own node is difficult to work with - so doing it this way:<br /><br /><cities><br /> <city><name>New Brunswick</name></city><br /> <city><name>San Diego</name></city><br /> <city><name>Yellowknife</name></city><br /></cities><br /><br />This lets you write code like this to populate the combo box:<br /><br />var cities = xfa.datasets.data.cities.resolveNodes("city[*]");<br /><br />for (var i = 0; i<cities.length; i++)<br />{<br /> this.addItem(cities.item(i).name.value);<br />}<br /><br />This finds the city nodes in the XML document and iterates through them, adding them to the drop-down list running this event.<br />--<br />SteveX<br />Adobe Systems

Avatar

Former Community Member
ok thanks



But how select or change the xml File or XML schema in run Time?

Avatar

Former Community Member
Hi steve



I do have a problem with this code. I would be very grateful if you can help me with this.



var cities = xfa.datasets.data.cities.resolveNodes("city[*]");

app.alert(cities.item(0).name.value);



This returns a null value which according to my understanding is that the cities variable does not hold any value.



app.alert(cities.item(1).name.value);



this returns an exception stating that the arrayindex is out of bounds.



This clearly shows that the array is not at all initialised from the values in the xml.



In the preasent code there is no reference made to the data source,if that is the case can you please tell me what has to be done about it.

Avatar

Former Community Member
In case of binding tab that is there in default binding is set as $record.city[*].name