![]() |
|
#1
|
|||
|
|||
|
I'm trying to find a way to look up values stored in a custom XML part, and as best I can figure, the method SelectByNamespace seems like the best way to make sure I have the right customXMLPart before I sort through the nodes. Does any one know a good reference on how to use this method?
The MSDN object library has the following example, but without the relevant XML script to go with it, I'm having a hard time understanding just what the ("urn:invoice:namespace") is matching to. it looks more like a namespace prefix than a URI to me but I may just be confused. HTML Code:
Dim cxp1 As CustomXMLParts
Dim cxn As CustomXMLNode
' Returns all of the custom xml parts with the given namespace.
Set cxp1 = ActiveDocument.CustomXMLParts.SelectByNamespace("urn:invoice:namespace")
' Get the node matching the XPath expression.
Set cxn = cxp1(1).SelectSingleNode("//*[@supplierID = 1]")
HTML Code:
<?xml version='1.0' ?> <data xmlns:c='comments' xmlns:a='applicant'> <a:Applicant> <a:FullName>AEP Texas Central Company</a:FullName> <a:AbbrName></a:AbbrName> <a:DateFiled></a:DateFiled> <a:Description></a:Description> </a:Applicant> </data> HTML Code:
Sub RetrieveNodeData()
Dim oCustomXMLPart As CustomXMLPart
Dim oNode As CustomXMLNode
Dim strCustPartID As String
** Set oCustomXMLPart = ActiveDocument.CustomXMLParts.SelectByNamespace("comments") **
Set oNode = oCustomXMLPart.SelectSingleNode("/a:root/a:Applicant/a:FullName")
strCustPartID = oNode.Text
MsgBox (strCustPartID)
End Sub
|
|
|