У меня есть код ниже, который пытается найти узел IssueMaterialPO в документе XML. Я не могу получить правильный XPath или у меня проблемы с пространством имен. Куда я могу пойти не так?
Dim doc As New XmlDocument
doc.Load(myXMLfile)
Dim nsMgr As New XmlNamespaceManager(doc.NameTable)
nsMgr.AddNamespace("ext_UserSchema", "http://Epicor.com/SC/UserSchema/")
nsMgr.AddNamespace("msg", "http://Epicor.com/InternalMessage/1.1/")
Dim nodeToFind As XmlNode
Dim root As XmlElement = doc.DocumentElement
nodeToFind = root.SelectSingleNode("/msg:Msg/msg:Body/msg:Req/msg:Dta/ext_UserSchema:BatchRecord/ext_UserSchema:ERP/ext_UserSchema:Transactions/ext_UserSchema:IssueMaterialPO", nsMgr)
If (nodeToFind Is Nothing) Then
MsgBox("Not Found")
Else
IMPO = True
MsgBox("Found")
End If
Он не находит IssueMaterialPO в XML ниже
<?xml version="1.0" encoding="utf-16"?>
<msg:Msg xsi:schemaLocation="http://Epicor.com/Message/2.0
http://scshost/schemas/epicor/ScalaMessage.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:msg="http://Epicor.com/Message/2.0">
<msg:Hdr>
<msg:Ctrl>
<msg:MsgID></msg:MsgID>
</msg:Ctrl>
<msg:Sender>
<msg:Name></msg:Name>
<msg:Subname></msg:Subname>
</msg:Sender>
<msg:Logon></msg:Logon>
</msg:Hdr>
<msg:Body>
<msg:Req msg-type="transaction" action="ConvertXML">
<msg:Dta>
<ext_UserSchema:BatchRecord xmlns:msg="http://Epicor.com/InternalMessage/1.1"
xmlns:ext_UserSchema="http://Epicor.com/SC/UserSchema">
<ext_UserSchema:RecordNumber>11340</ext_UserSchema:RecordNumber>
<ext_UserSchema:Date>2012-03-09</ext_UserSchema:Date>
<ext_UserSchema:ERP>
<ext_UserSchema:Transactions>
<ext_UserSchema:IssueMaterialPO>
<ext_UserSchema:Bin>BIN</ext_UserSchema:Bin>
<ext_UserSchema:OrderNumber>555555</ext_UserSchema:OrderNumber>
<ext_UserSchema:InventoryCategory>O</ext_UserSchema:InventoryCategory>
<ext_UserSchema:LotNumber>678</ext_UserSchema:LotNumber>
<ext_UserSchema:ItemNumber>12-345</ext_UserSchema:ItemNumber>
<ext_UserSchema:Quantity>10</ext_UserSchema:Quantity>
<ext_UserSchema:Stockroom>01</ext_UserSchema:Stockroom>
</ext_UserSchema:IssueMaterialPO>
</ext_UserSchema:Transactions>
</ext_UserSchema:ERP>
</ext_UserSchema:BatchRecord>
</msg:Dta>
</msg:Req>
</msg:Body>
</msg:Msg>