Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-21-2012, 11:52 AM
RobsterCraw RobsterCraw is offline CustomXMLParts.SelectByNamespace Windows 7 32bit CustomXMLParts.SelectByNamespace Office 2010 32bit
Novice
CustomXMLParts.SelectByNamespace
 
Join Date: Nov 2012
Posts: 11
RobsterCraw is on a distinguished road
Default CustomXMLParts.SelectByNamespace

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]")
My .xml looks like this:


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>
And my Function looks mike this:
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
I get a runtime error '13': Type Mismatch on the line with the **
Reply With Quote
 



Other Forums: Access Forums

All times are GMT -7. The time now is 10:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft