xmlAttr FunctionReturns the value of an XML element's attribute. Syntaxvalue = xmlAttr(el, attr, defVal); Parameters
ReturnsReturns the value of the attribute, or defVal if the attribute does not exist. Example 1<CUSTOM_FOO CENTER="1"> ... </CUSTOM_FOO> var center = xmlAttr(xmlLocData, "CENTER", 0); The variable center will be set to "1". Example 2<CUSTOM_FOO> <FOO FOO="Foo Value" /> </CUSTOM_FOO> xmlEl = xmlChildOf(xmlLocData, "FOO", 0); spanFoo.innerText = xmlAttr(xmlEl, "FOO", "No Foo specified"); spanBar.innerText = xmlAttr(xmlEl, "BAR", "No Bar specified"); The HTML element spanFoo will display Foo Value, while spanBar will display No Bar specified. |