Привет, у меня есть xml файлы, я пытаюсь использовать xpath, получая значение атрибута "mapfile" из xml (показано ниже), а затем получая все значения "ключа" из внешнего mapfile, с которым я могу справиться без проблем.
Затем мне нужно получить все "ключевые" числа из файла xml ниже, которые соответствуют этому файлу карты. Проблема в том, что я могу вытащить их все, но мне нужно вытащить их и проверить по каждому файлу отдельно, а не по целому лоту.
xml разделен на «разделы списка» каждый «раздел списка» имеет файл карты. Я хочу проверить значения «ключа» в «разделе списка» по отношению к значениям «ключа» в файле карты.
так что я попробовал:
//get the list of mapfiles
XmlNodeList mapfiles = xmlDoc.SelectNodes("//a:listsection/a:views/a:explodeddiagram", nsmgr);
//get the mapfiles
foreach (XmlNode mapfile in mapfiles)
{
string mapfilename = mapfile.Attributes["mapfile"].Value;
//load the mapfile and read it and get the key values from it.
XmlDocument xmlDockey = new XmlDocument();
xmlDochot.Load(parentdir + "\\" + mapfilename);
XmlNodeList xmlkeyfrommapfile = xmlDockey.SelectNodes("//*[name()='area'][@key]");
foreach (XmlNode keynode in xmlkeyfrommapfile)
{
string keyTextmapfile = keynode.Attributes["key"].Value;
//So here i've got all the values I need for each "mapfile"
list1.Add(keyTextmapfile );
}
}
//now I get the values of the "key" from the xml file (xml shown below)
//get the values for the keys from the list file (xml shown below)
XmlNodeList keysfromlistfile = xmlDoc.SelectNodes("//*[name()='key']");
foreach (XmlNode keyfromlistfile in keysfromlistfile)
{
string keyTextlistfile = keyfromlistfile.InnerText;
list2.Add(keyTextlistfile);
}
Итак, чтобы повторить: Я получаю всю партию. Я просто хочу проверить каждый файл на наличие «ключевых» значений в одном и том же «разделе списка». Существует несколько «разделов списка», иногда превышающих 20.
<Thislist>
<listsection>
<views>
<explodeddiagram title="Some image title1" graphicfile="SomeFilename1.tif" mapfile="SomeFilename1.xml" />
</views>
<rows>
<row>
<key>1</key>
<remark>(Generic Remark 1)</remark>
<part>
<number>25376.0000</number>
<description>Generic Description</description>
</part>
<qty>1</qty>
</row>
<row>
<key>2</key>
<remark>(Generic Remark 4)</remark>
<part>
<number>253767890002</number>
<description>Generic Description</description>
</part>
<qty>1</qty>
</row>
<row>
<key>2</key>
<remark>(Generic Remark 3)</remark>
<part>
<number>253764560001</number>
<description>Generic Description</description>
</part>
<qty>1</qty>
</row>
<row>
<key>3</key>
<remark>(Generic Remark 5)</remark>
<part>
<number>209213231004</number>
<description>Generic Description</description>
</part>
<qty>1</qty>
</row>
</rows>
</listsection>
<listsection>
<views>
<explodeddiagram title="Some image title2" graphicfile="SomeFilename2.tif" mapfile="SomeFilename2.xml" />
</views>
<rows>
<row>
<key>1</key>
<remark>(Generic Remark 6)</remark>
<part>
<number>25376656560000</number>
<description>Cover Assy, Top SST</description>
</part>
<qty>1</qty>
</row>
<row>
<key>2</key>
<remark>(Generic Remark 7)</remark>
<part>
<number>2537677902</number>
<description>Generic Description</description>
</part>
<qty>1</qty>
</row>
<row>
<key>2</key>
<remark>(Generic Remark 8)</remark>
<part>
<number>25376457881</number>
<description>Generic Description</description>
</part>
<qty>1</qty>
</row>
<row>
<key>3</key>
<remark>(Generic Remark 9)</remark>
<part>
<number>209288004</number>
<description>Generic Description</description>
</part>
<qty>1</qty>
</row>
</rows>
</listsection>
</Thislist>
Пример файла карты
<?xml version="1.0" encoding="utf-8"?>
<mapfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="hotspot.xsd">
<map name="SomeMapName">
<area shape="rect" coords="169,210,199,252" key="3" />
<area shape="rect" coords="2094,881,2124,924" key="1" />
<area shape="rect" coords="2094,1031,2124,1074" key="2" />
<area shape="rect" coords="2094,1145,2124,1187" key="6" />
</map>
</mapfile>