C
CueneydErbay
My question is how I can change a value of an attribute in an xml file
I loaded before.
I tried the method setAttribute("attribute name", "attribute value")
but it doesn't work.
That's my sample xml file:
<?xml version="1.0" encoding="iso-8859-1" ?>
<KdStamm>
<customer id="001" address="hannover" lon="" lat="" info="test"></
customer>
<customer id="002" address="munich" lon="" lat="" info="test"></
customer>
<customer id="003" address="hamburg" lon="" lat="" info="test"></
customer>
</KdStamm>
and that's an extract of my code (I loaded the xml file already
before):
customers = xml_doc.getElementsByTagName("customer");
// iterate through all nodes ( customer )
for(i = 0; i < customers.length; i++)
{
if (customers.nodeType==1)
{
CustomersItem = customers.item(i);
var lon = CustomersItem.getAttribute("lon");
var lat = CustomersItem.getAttribute("lat");
var htmlContent = CustomersItem.getAttribute("info");
// if lon & lat == "" then get coordinates out of the
address
if ( lon == "" & lat =="")
{
var XMLaddress =
CustomersItem.getAttribute("address");
geocode(XMLaddress);
lon = gLon;//global variable with longitude coordinate
lat = gLat; // global variable with latitude
coordinate
alert(gLon + " " + gLat);
}
// change attributes lon and lat out of node, problem
starts with these lines
CustomersItem.setAttribute("lon", lon);
CustomersItem.setAttribute("lat", lat);
}
I don't know why but I can't change the values of the attributes.
Thanks in advance.
Cüneyd
I loaded before.
I tried the method setAttribute("attribute name", "attribute value")
but it doesn't work.
That's my sample xml file:
<?xml version="1.0" encoding="iso-8859-1" ?>
<KdStamm>
<customer id="001" address="hannover" lon="" lat="" info="test"></
customer>
<customer id="002" address="munich" lon="" lat="" info="test"></
customer>
<customer id="003" address="hamburg" lon="" lat="" info="test"></
customer>
</KdStamm>
and that's an extract of my code (I loaded the xml file already
before):
customers = xml_doc.getElementsByTagName("customer");
// iterate through all nodes ( customer )
for(i = 0; i < customers.length; i++)
{
if (customers.nodeType==1)
{
CustomersItem = customers.item(i);
var lon = CustomersItem.getAttribute("lon");
var lat = CustomersItem.getAttribute("lat");
var htmlContent = CustomersItem.getAttribute("info");
// if lon & lat == "" then get coordinates out of the
address
if ( lon == "" & lat =="")
{
var XMLaddress =
CustomersItem.getAttribute("address");
geocode(XMLaddress);
lon = gLon;//global variable with longitude coordinate
lat = gLat; // global variable with latitude
coordinate
alert(gLon + " " + gLat);
}
// change attributes lon and lat out of node, problem
starts with these lines
CustomersItem.setAttribute("lon", lon);
CustomersItem.setAttribute("lat", lat);
}
I don't know why but I can't change the values of the attributes.
Thanks in advance.
Cüneyd