0
我對XML相當陌生,無法使用VB解析下面的文件。我想要做的是,轉到文件中最後的<SESSION>
標記,並循環訪問<IMAGE>
節點並獲取它們的值。另一個元素的最後一次出現的XML分析元素
<?xml version="1.0" encoding="UTF-8"?>
<MIFORMS_EXPORT>
<SESSION FORM_ID="209688" CID="" ID="HAKKI-LAPTOP_634995474247656192">
<FIELD NAME="A001DATE_M" />
<FIELD NAME="A002" />
<FIELD NAME="A003" />
<FIELD NAME="A004" />
<IMAGE NAME="P1" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-0-03222013-111042768-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P2" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-1-03222013-111042783-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P3" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-2-03222013-111042799-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P4" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-3-03222013-111042814-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P5" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-4-03222013-111042830-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P6" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-5-03222013-111042846-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P7" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-6-03222013-111042846-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P8" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-7-03222013-111042861-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P9" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-8-03222013-111042877-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P10" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-9-03222013-111042892-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
<IMAGE NAME="P11" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-10-03222013-111042892-HAKKI-LAPTOP_634995474247656192.png</IMAGE>
</SESSION>
<SESSION FORM_ID="209688" CID="" ID="HAKKI-LAPTOP_634995479807027960">
<FIELD NAME="A001DATE_M" />
<FIELD NAME="A002" />
<FIELD NAME="A003" />
<FIELD NAME="A004" />
<IMAGE NAME="P1" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-0-03222013-111944041-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P2" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-1-03222013-111944056-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P3" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-2-03222013-111944072-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P4" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-3-03222013-111944088-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P5" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-4-03222013-111944103-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P6" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-5-03222013-111944119-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P7" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-6-03222013-111944134-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P8" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-7-03222013-111944134-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P9" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-8-03222013-111944150-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P10" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-9-03222013-111944166-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
<IMAGE NAME="P11" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">C:\wamp\www\Kapture.web\ClientBin\metis\images\209688-10-03222013-111944212-HAKKI-LAPTOP_634995479807027960.png</IMAGE>
</SESSION>
</MIFORMS_EXPORT>
我走了這麼遠:
'TASK: Get the pen image PNG name
'Get the total Session count in XML
Dim penImageRaw As Int32 = doc.GetElementsByTagName("SESSION").Count
For startValue = 0 To penImageRaw
i+=1
Next
'Grab the last session element
Dim test As XmlNode = doc.GetElementsByTagName("SESSION").Item(i)
感謝您的幫助。
Hm,「'現在在這個SESSION節點裏找到IMAGE節點這裏」...我該怎麼做? test.intellisense沒有給我一個明確的方法來獲取IMAGE節點。 – IHS88 2013-03-22 12:05:58
昏暗penImageRaw作爲的Int32 = doc.GetElementsByTagName( 「會話」)。計數 如果penImageRaw> 0然後 「抓住最後的會話元件(最後一個是計數-1) 昏暗測試作爲XmlNode的= doc.GetElementsByTagName(「SESSION 「).Item(penImageRaw-1) 昏暗列表作爲XmlNodeList中= test.ChildNodes 對於每個節點的XmlNode在列表 \t如果String.Equals(node.Name, 「圖像」) \t \t 昏暗WTF作爲字符串= node.FirstChild.Value \t \t MsgBox(wtf) End If \t Next Else MsgBox(「No Session nodes found」) End If – IHS88 2013-03-22 14:18:36
解決了它。這是工作代碼。我不能回答我自己的問題,所以必須這樣做,將在5小時內回來,並提交一個適當的答案。 謝謝扎夫指着我朝着正確的方向前進。 – IHS88 2013-03-22 14:19:37