Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XPath expression to a custom property in Word 2007 ? >Thread Next - Re: XPath expression to a custom property in Word 2007 ? Re: XPath expression to a custom property in Word 2007 ?To: NULL Date: 11/8/2008 7:30:00 PM Kay-Christian Wessel wrote: > I'm trying to map a custom property of a Word 2007 document to a > contentcontrol. > > Mapping is not so hard : > > Dim strXPath As String > strXPath = "tree/fruit/fruitType[1]" > ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath > > But setting the right XPath is is giving me a hard time. > > Here is the custom XML file : > > <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> > - <Properties > xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" > xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"> > > - <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" > name="MyFirstCustomProperty"> > <vt:lpwstr>FirstText</vt:lpwstr> > </property> > - <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" > name="MySecondCustomProperty"> > <vt:lpwstr>SecondText</vt:lpwstr> > </property> > </Properties> > > > What would be the correct XPath expression to MySecondCustomProperty ? It is not clear what you want to achieve. "MySecondCustomProperty" is an attribute value in your XML sample. Do you want an XPath expression evaluating to that attribute value? I suspect you want to select the "property" element having a "name" attribute with value "MySecondCustomProperty". One way to do that is /*[local-name() = "Properties"]/*[local-name() = "property"][@name = "MySecondCustomProperty"] Or you need to bind prefixes to namespace URIs and use those prefixes. I don't know how you do that with Word 2007 but assuming the prefix "cp" is bound to the namespace URI "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" you can use /cp:Properties/cp:property[@name = "MySecondCustomProperty"] -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
