xmlRetrieve FunctionGets data from a specified path of elements, starting at the root. Syntaxvalue = xmlRetrieve(elPath, defVal, index, retrNum); Parameters
ReturnsReturns either the number of elements, the contents of an element, or an attribute value, based on the parameters. RemarksAn attribute can only be specified at the end of a path. The xmlRetrieveEx function performs the same operations, but with more flexibility. Example 1<GLOBAL> <CUSTOM_FOO> <BAR>Inside Global Bar</BAR> </CUSTOM_FOO> </GLOBAL> spanFoo.innerText = xmlRetrieve( "GLOBAL/CUSTOM_FOO/FOO", "Default Global Foo", 0, 0); spanBar.innerText = xmlRetrieve( "GLOBAL/CUSTOM_FOO/BAR", "Default Global Bar", 0, 0); The HTML element spanFoo will display Default Global Foo, while spanBar will display Inside Global Bar. Example 2<GLOBAL> <CUSTOM_FOO COLOR="#FF00FF"> <BAR COLOR="#00FF00"/> </CUSTOM_FOO> </GLOBAL> spanFoo.style.color = xmlRetrieve( "GLOBAL/CUSTOM_FOO:COLOR", "#000000", 0, 0); spanBar.style.color = xmlRetrieve( "GLOBAL/CUSTOM_FOO/BAR:COLOR", "#FFFFFF", 0, 0); The HTML element spanFoo will have the color #FF00FF, while spanBar will have the color #00FF00. Example 3<GLOBAL> <CUSTOM_FOO> <BAR VALUE="Bar 1"/> <BAR/> <BAR VALUE="Bar 3"/> </CUSTOM_FOO> </GLOBAL> val = xmlRetrieve("GLOBAL/CUSTOM_FOO/BAR:VALUE", "Default", 0, 0); spanBar.insertAdjacentText("beforeEnd", val + "... "); val = xmlRetrieve("GLOBAL/CUSTOM_FOO/BAR:VALUE", "Default", 1, 0); spanBar.insertAdjacentText("beforeEnd", val + "... "); val = xmlRetrieve("GLOBAL/CUSTOM_FOO/BAR:VALUE", "Default", 2, 0); spanBar.insertAdjacentText("beforeEnd", val + "... "); numBars = xmlRetrieve("GLOBAL/CUSTOM_FOO/BAR", "", 0, 1); for(i = 0; i < numBars; i++) { val = xmlRetrieve( "GLOBAL/CUSTOM_FOO/BAR:VALUE", "Default", i, 0); spanBar.insertAdjacentText("beforeEnd", val + "... "); } The HTML element spanBar will display Bar 1... Default... Bar 3... . Both script fragments achieve the same result. |