My goal is to import a XML file from the site fueleconomy.gov to get a list of cars dependent on the year given as the user input .
Here is the code:
years = Import["http://www.fueleconomy.gov/ws/rest/vehicle/menu/year", "XML"];
y = Cases[years, XMLElement["menuItem", _, _], Infinity] /.
XMLElement[_, _, {val_}] -> val /.
XMLElement["menuItem", _, list_] -> list;
Do[y[[i]] = DeleteDuplicates[y[[i]]], {i, 1, Length[y], 1}];
years = y[[All, 1]]
PopupMenu[Dynamic[year], years]
makes = Import[
StringJoin[
"http://www.fueleconomy.gov/ws/rest/vehicle/menu/make?year=",
year], "XML"];
I tried to put Dynamic[year] instead of year but it crashes en got this error:
"String expected at position 2 in
http://www.fueleconomy.gov/ws/rest/vehicle/menu/make?year=<>2014"
My question is why StringJoin put '<>' in the url in the error message. I used the same function before and it worked, any ideas?

Dynamicputs an invisible wrapper around its argument so thatStringJoindoes not see it as a String anymore.yearitself is a number and no String, so you should useToStringon it. The<>in the error message is simply the infix form ofStringJoin(see its doc page). – Sjoerd C. de Vries Jul 22 '15 at 10:24I see this references and year is a string the xml file have two elements text and value and i get text Also i try to put Dynamic[..] englobing makes =Import[...] and it works
– Alberto Jul 22 '15 at 10:38makesvariable updated automatically when the user selects a new year from the pop-up menu? – Sjoerd C. de Vries Jul 22 '15 at 10:43Dynamic. I was surely one of them. It is a true "pitfall" IMHO. – Mr.Wizard Jul 22 '15 at 11:17