<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>XML</title><revhistory><revision><revnumber>2</revnumber><date>2017-05-28 03:01:03</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>1</revnumber><date>2015-08-10 00:16:12</date><authorinitials>LKD70</authorinitials></revision></revhistory></articleinfo><section><title>XML Functions</title><section><title>xml()</title><para>The <emphasis role="strong">xml()</emphasis> function allows you to manipulate xml files/links by fetch the data from within them. </para><section><title>XML Example</title><screen><![CDATA[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)]]></screen><para>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 &quot;report&quot;. </para><!--rule (<hr>) is not applicable to DocBook--></section></section></section><section><title>GetFortsFromXML()</title><para>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 = &quot;count&quot;). </para><section><title>Forts Example</title><screen><![CDATA[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)]]></screen><para>This example shows us creating a FortificationsBean object under the variable 'forts'. The object contains the forts information from the XML report. </para><!--rule (<hr>) is not applicable to DocBook--></section></section><section><title>GetTroopsFromXML()</title><para>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 = &quot;count&quot;) This functions replaces no longer available xmlTroopsToTroopBean() function. </para><section><title>Troops Example</title><screen><![CDATA[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)]]></screen><para>This example shows us creating a TroopBean object under the variable 'troops'. The object contains the troop information from the XML report. </para><!--rule (<hr>) is not applicable to DocBook--></section></section><section><title>GetResourcesFromXML()</title><para>Same purpose as troops and fortifications above.. but for resources. </para><section><title>Resources Example</title><screen><![CDATA[// 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]]></screen><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="http://guide.neatportal.com/wiki/XML/wiki/CategoryFunctions#">CategoryFunctions</ulink> </para></section></section></article>