This is the snippet of the XML file that I access via a [URL][1] that I need to focus on.
<imgdir name="portal">
<imgdir name="0">
<string name="pn" value="sp"/>
<int name="pt" value="0"/>
<int name="x" value="-288"/>
<int name="y" value="27"/>
<int name="tm" value="999999999"/>
<string name="tn" value=""/>
</imgdir>
<imgdir name="1">
<string name="pn" value="in00"/>
<int name="pt" value="7"/>
<int name="x" value="74"/>
<int name="y" value="154"/>
<int name="tm" value="999999999"/>
<string name="tn" value=""/>
<int name="horizontalImpact" value="0"/>
<string name="script" value="talkToMai"/>
<int name="hideTooltip" value="0"/>
<int name="onlyOnce" value="0"/>
<int name="delay" value="0"/>
</imgdir>
<imgdir name="2">
<string name="pn" value="sp"/>
<int name="pt" value="0"/>
<int name="x" value="-349"/>
<int name="y" value="-45"/>
<int name="tm" value="999999999"/>
<string name="tn" value=""/>
</imgdir>
<imgdir name="3">
<string name="pn" value="sp"/>
<int name="pt" value="0"/>
<int name="x" value="257"/>
<int name="y" value="132"/>
<int name="tm" value="999999999"/>
<string name="tn" value=""/>
</imgdir>
<imgdir name="4"> // PLOT THIS PORTAL
<string name="pn" value="east00"/>
<int name="pt" value="2"/>
<int name="x" value="683"/>
<int name="y" value="211"/>
<int name="tm" value="4000026"/>
<string name="tn" value="west00"/>
<int name="horizontalImpact" value="0"/>
<string name="script" value=""/>
<int name="hideTooltip" value="0"/>
<int name="onlyOnce" value="0"/>
<int name="delay" value="0"/>
</imgdir>
<imgdir name="5">
<string name="pn" value="sp"/>
<int name="pt" value="0"/>
<int name="x" value="213"/>
<int name="y" value="101"/>
<int name="tm" value="999999999"/>
<string name="tn" value=""/>
</imgdir>
<imgdir name="6"> // PLOT THIS PORTAL
<string name="pn" value="west00"/>
<int name="pt" value="2"/>
<int name="x" value="-426"/>
<int name="y" value="212"/>
<int name="tm" value="4000020"/>
<string name="tn" value="east00"/>
<string name="script" value=""/>
<int name="hideTooltip" value="0"/>
<int name="delay" value="0"/>
<int name="onlyOnce" value="0"/>
</imgdir>
</imgdir>
</imgdir>
I already read through the same XML but a different section in this fashion.
public static int getWidth(string id)
{
try
{
var uri = "http://[redacted]/INFO/" + id + ".img.xml";
var doc = XDocument.Load(uri);
return (int)doc.Descendants("int").First(x => (string)x.Attribute("name") == "width").Attribute("value");
}
catch
{
return 0;
}
}
If you look at the snippet of the XML file I posted above, you will notice that I put comments on the "portals" I need to plot onto my map (portals # 4 & 6). What I do not understand is how can I edit the above function to loop through the "portals" and check if the portal names 'pn' and 'tn' contain a value (does not matter what the value is) and to check if the additional name 'tm' does not contain the value 999999999, and if the aforementioned is all 'true', then to grab the x and y values and use them to draw the portal, and loop ofc for rest of the portals.
I already have the draw function and what not, I just do not understand how to loop through the XML code posted, check for certain names and values (pn & tn & tm), then to grab the x and y if it meets the conditions, and then finally use it in the draw function and repeat until nothing left.
I hope you understand this, thanks.