= XML Functions = <> == xml() == The '''xml()''' function allows you to manipulate xml files/links by fetch the data from within them. ==== XML Example ==== {{{ url = "http://battleXXXXX.evony.com/logfile/20150810/AA/BB/ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.xml" get url if $error die "Failed to load the xml file {url}." report = xml($result) }}} In this example if the URL was successfully loaded it will attempt to extract any XML values from it. These are applied to the variable "report". ---- == GetFortsFromXML() == This converts fortifications in an XML list to a !FortificationsBean. An optional second parameter can specify a property name containing the number of fortifications (default = "count"). ==== Forts Example ==== {{{ url = "http://battleXXXXX.evony.com/logfile/20150810/AA/BB/ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.xml" get url if $error die "Failed to load the XML file {url}." report = xml($result) forts = GetFortsFromXML(report.scoutReport.scoutInfo.fortifications.fortificationsType) }}} This example shows us creating a !FortificationsBean object under the variable 'forts'. The object contains the forts information from the XML report. ---- == GetTroopsFromXML() == This converts troops in an XML list to a !TroopBean. An optional second parameter can specify a property name containing the number of troops (default = "count") This functions replaces no longer available xmlTroopsToTroopBean() function. ==== Troops Example ==== {{{ url = "http://battleXXXXX.evony.com/logfile/20150810/AA/BB/ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.xml" get url if $error end report = xml($result) troops = GetTroopsFromXML(report.scoutReport.scoutInfo.troops.troopStrType) }}} This example shows us creating a !TroopBean object under the variable 'troops'. The object contains the troop information from the XML report. ---- == GetResourcesFromXML() == Same purpose as troops and fortifications above.. but for resources. ==== Resources Example ==== {{{ // requires valid report url with "default.html?" removed url = "http://battleXXXXX.evony.com/logfile/20150710/AA/BB/ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.xml" get url if $error end report = xml($result) res = GetResourcesFromXML(report.battleReport.lootResource) if res echo "Resources: " + res }}} ---- CategoryFunctions