xmlRetrieveEx FunctionGets the XML data from a specified element or attribute. Syntaxvalue = xmlRetrieveEx(elStart, elPath, attr, defVal, retrNum); Parameters
ReturnsReturns either the number of elements, the contents of an element, or an attribute value, based on the parameters. RemarksThe xmlRetrieve function performs the same operations, but with less flexibility. Example 1<GLOBAL> <CUSTOM_FOO> <BAR>Inside Global Bar</BAR> </CUSTOM_FOO> </GLOBAL> spanFoo.innerText = xmlRetrieveEx(null, "GLOBAL[0]/CUSTOM_FOO[0]/FOO[0]", "", "Default Global Foo", 0); spanBar.innerText = xmlRetrieveEx(null, "GLOBAL[0]/CUSTOM_FOO[0]/BAR[0]", "", "Default Global Bar", 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 = xmlRetrieveEx(null, "GLOBAL[0]/CUSTOM_FOO[0]", "COLOR", "#000000", 0); spanBar.style.color = xmlRetrieveEx(null, "GLOBAL[0]/CUSTOM_FOO[0]/BAR[0]", "COLOR", "#FFFFFF", 0, 0); The HTML element spanFoo will have the color #FF00FF, while spanBar will have the color #00FF00. Example 3<LOC ID="3" TYPE="CUSTOM_FOO"> <HEADING>Foo</HEADING> <CUSTOM_FOO> <BARS> <BAR VALUE="Bar 1"/> <BAR/> <BAR VALUE="Bar 3"/> </BARS> </CUSTOM_FOO> </LOC> spanHead.innerText = xmlRetrieveEx(xmlCurLoc, "HEADING[0]", "", "No Heading", 0); val = xmlRetrieveEx(xmlLocData, "BARS[0]/BAR[0]", "VALUE", "Default", 0); val += "... "; val += xmlRetrieveEx(xmlLocData, "BARS[0]/BAR[1]", "VALUE", "Default", 0); val += "... "; val += xmlRetrieveEx(xmlLocData, "BARS[0]/BAR[2]", "VALUE", "Default", 0); val += "... "; spanBar.innerText = val; spanHead.innerText = xmlRetrieveEx(xmlCurLoc, "HEADING[0]", "", "No Heading", 0); numBars = xmlRetrieveEx(xmlLocData, "CUSTOM_FOO[0]/BAR", "", 0, 1); val = ""; for(i = 0; i < numBars; i++) { val += xmlRetrieveEx(xmlLocData, "BARS[0]/BAR["+i+"]", "VALUE", "Default", 0); val += "... "; } spanBar.innerText = val; The HTML element spanHead will contain Foo; the element spanBar will display Bar 1... Default... Bar 3... . Both script fragments achieve the same result. |