> Try setting the namespace "my" by setting the "SelectionNamespaces" property
> using "setProperty" on the DOM, before you start using XPath expressions to
> find nodes. Search this newsgroup on "SelectionNamespaces" to find out how to
> do this.
> ---
> S.Y.M. Wong-A-Ton
>
>
> "pearsond" wrote:
>
> > Hi,
> >
> > I am using the following code to open a new form from within an InfoPath
> > form and set a value of a field. However, I receive the following error:
> > System.Runtime.InteropServices.COMException
> > Reference to undeclared namespace prefix: 'my'.
> >
> > Here is my code:
> > XDocumentsCollection docCollection = thisApplication.XDocuments;
> > XDocument newForm = docCollection.NewFromSolution([ at ]"C:\Documents and
> > Settings\PearsonD\My Documents\MultiForm\Supporting.xsn");
> > newForm.DOM.selectSingleNode("/my:myFields/my:field1").text = "hello";
> >
> > Here is xml from the form I'm trying to populate:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <?mso-infoPathSolution solutionVersion="1.0.0.1" productVersion="11.0.6565"
> > PIVersion="1.0.0.0"
> > href="file:///C:\Documents%20and%20Settings\PearsonD\My%20Documents\Supporting.xsn"
> > name="urn:schemas-microsoft-com:office:infopath:Supporting:-myXSD-2006-07-13T14-17-26" ?>
> > <?mso-application progid="InfoPath.Document"?>
> > <my:myFields
> > xmlns:my="
http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-07-13T14:17:26" xml:lang="en-us">
> > <my:field1>Test Data</my:field1>
> > </my:myFields>
> >
> > I greatly appreciate any assistance. Thank you.