warmdownhere
Programmer
I'm trying to convert a string to xml and then fill a select box with that info. Not working Thoughts?
var test = "<NewDataSet<Table><GenreID>d0e583d7-393d-47b1-8f47-e1b814e6d7c6</GenreID><Name>Politics</Name></Table><Table><GenreID>37f4a8ad-98d8-4b2c-9c30-4e2ff00dee2a</GenreID><Name>Shopping</Name></Table></NewDataSet>";
var xmlobject = (new DOMParser()).parseFromString(test, "text/xml");
// get a reference to the root-element "NewDataSet"
var root = xmlobject.getElementsByTagName('NewDataSet')[0];
// get reference to "table" element
var Tables = root[0].getElementsByTagName("Table");
// in the "table" we have a GenreID, so get that
var genreID = Tables[0].getElementsByTagName("GenreID");
var name = Tables[0].getElementsByTagName("Name");
for (i=0;i<=genreID.length;i++)
{
document.forms['genreform'].genre.options[0] = new Option(name,genreID);
}
Thanks,
Ted
var test = "<NewDataSet<Table><GenreID>d0e583d7-393d-47b1-8f47-e1b814e6d7c6</GenreID><Name>Politics</Name></Table><Table><GenreID>37f4a8ad-98d8-4b2c-9c30-4e2ff00dee2a</GenreID><Name>Shopping</Name></Table></NewDataSet>";
var xmlobject = (new DOMParser()).parseFromString(test, "text/xml");
// get a reference to the root-element "NewDataSet"
var root = xmlobject.getElementsByTagName('NewDataSet')[0];
// get reference to "table" element
var Tables = root[0].getElementsByTagName("Table");
// in the "table" we have a GenreID, so get that
var genreID = Tables[0].getElementsByTagName("GenreID");
var name = Tables[0].getElementsByTagName("Name");
for (i=0;i<=genreID.length;i++)
{
document.forms['genreform'].genre.options[0] = new Option(name,genreID);
}
Thanks,
Ted