Okay, I'm using BlackRain to, well right now to get a list of the surrounding nodes and give their names, locations, and entry #'s.
Everything works so far, except for the node's name...
It is supposed to retrieve the name of the node from an XML file.(below) It searches the XML file for an element (Mineral) who's Entry attribute matches the node's entry #.
Troublesome code:
Code:
privatevoid button1_Click(object sender, System.EventArgs e)
{
XPathDocument xPathDocument = newXPathDocument("ResourceList.xml");
XPathNavigator xPathNavigator = xPathDocument.CreateNavigator();
//Take out exisiting entries
Objects_lst.Items.Clear();
foreach (WowObject gather inObjectManager.Objects)
{
if (gather.X != 0 && gather.Y != 0 && gather.Z != 0 && gather.Type == 5)
{
//string nodeName = (string)xPathNavigator.Evaluate("string(//ResourceList/Mineral[@Entry="+gather.Entry+"]/Name/text())");
//Hard-coded the value for copper instead...
//Gets the Name of the mineral/herb from an XML file based on the Entry#
string nodeName = (string)xPathNavigator.Evaluate("string(//ResourceList/Mineral[@Entry=1731]/Name/text())");
if (nodeName == null)
{
nodeName = "Unknown";//If nothing is there, catch the null value, and stop it from breaking something.
}
//Finally, add the Item to the list With the format:( X: -100.9 | Y: 351.379 | Z: 12.48 | Entry: 1731 | Name: Copper Vein )
Objects_lst.Items.Add(string.Format("X: {0} | Y: {3} | Z: {4} | Entry: {1} | Name: {2}", gather.X,
gather.Entry, nodeName, gather.Y, gather.Z));
}
}
}
Code:
<?xmlversion="1.0"encoding="utf-8"?>
<ResourceListxmlns="http://tempuri.org/XMLSchema.xsd">
<MineralEntry="1731">
<Name>Copper Vein</Name>
<Entry>1731</Entry>
<MinSkill>1</MinSkill>
</Mineral>
<MineralEntry="1732">
<Name>Tin Vein</Name>
<Entry>1732</Entry>
<MinSkill>65</MinSkill>
</Mineral>
<MineralEntry="1733">
<Name>Silver Vein</Name>
<Entry>1733</Entry>
<MinSkill>1</MinSkill>
</Mineral>
<MineralEntry="1735">
<Name>Iron Deposit</Name>
<Entry>1735</Entry>
<MinSkill>125</MinSkill>
</Mineral>
<MineralEntry="1734">
<Name>Gold Vein</Name>
<Entry>1734</Entry>
<MinSkill>175</MinSkill>
</Mineral>
<MineralEntry="2040">
<Name>Mithril Deposit</Name>
<Entry>2040</Entry>
<MinSkill>175</MinSkill>
</Mineral>
<MineralEntry="2047">
<Name>Truesilver Deposit</Name>
<Entry>2047</Entry>
<MinSkill>205</MinSkill>
</Mineral>
<MineralEntry="165658">
<Name>Dark Iron Deposit</Name>
<Entry>165658</Entry>
<MinSkill>230</MinSkill>
</Mineral>
<MineralEntry="324">
<Name>Small Thorium Vein</Name>
<Entry>324</Entry>
<MinSkill>320</MinSkill>
</Mineral>
If nothing else, does anyone have a better way than XML to retrieve the mineral's name? The XPath expression works fine on BIT-101 XPath Query Tool... So I am at a loss as to why it won't work at run-time...
Any help would be greatly appreciated.