xpath references

P

Paul Mayer

I have a question regarding Xpath references?
When do you use the /dfs:???? /my:???? or the @ references
as part of the reference to the data source. I thought I had figured
it out my now im more confused. Especially with the nested
fields in the data source. Does the position of a field or group
affect the Xpath reference? For example a field directly under the
myFields reference as compared to a field that is after the queryFields
and dataFields (from a data connection). Please see below. Do
variables A and B do the generate the same top level references
/my:myfields/my:??? ? What about references to Indx under the
queryFields and dataFields? What about references for Group C or
references for secondary data connections.
Are there some fast quick rules for how to make reference to fields?
Is there some place online that will help me better understand how to
make xpath references?

-myFields
-A
-queryFields
-Indx (Auto Number field)
-TxtString (A text string)
-dataFields
-Indx
-TxtString
-B
-C (Group)
-SomeNum
-SomeTxt
 
H

Hilary Stoupa

Hi there --

If you have InfoPath 2007 you can right click a field in the data source
task pane and select copy XPath to get a field's xpath. Super helpful.

However, it is always good to understand namespaces (which is where the
'my', 'dfs', 'd' etc come in).

One way to find the XPath to a field in IP2003 is to create a formula (say,
for a default value or a rule) and add the field you'd like to know the XPath
to into the formula, then select the checkbox that says Edit XPath. That may
help you figure out your namespaces.

In a sample form I set up, that was created off a data source but has
additional fields added to the main data source (like your field A), the
XPath is: /dfs:myFields/my:a. As you can see, myFields uses the 'dfs'
namespace, but the field added within InfoPath uses the 'my' namespace.

A field listed under the dataFields group, inside another group (namespace
'd') looks like this:
/dfs:myFields/dfs:dataFields/d:Test1/@ID

@ID is probably the equivalent of your Indx field -- but I don't see a group
related to your data table in the schema described (d:Test1 is related back
to my table)

One last trick -- extract your form files and open sampledata.xml in notepad
(or text or xml editor of your choice). It will show you the xml for your
data structure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top