why object required in selectsinglenode

M

Mint

i want to click the button and it alerts the text that filds in.
my fields is:
myFields
test
i use the code:
XDocument.UI.Alert(XDocument.DOM.selectSingleNode("/myFields/test").text);
but failed , it warns that "Object required!"
i have read the SDK,the sample code also uses the code like mine.why
the sampale can use it, not mine?
i change the code to:
XDocument.UI.Alert(XDocument.DOM.selectSingleNode("//my:myFields/my:test").text);
it is ok.
is there any difference?
can anyone help me ?
when will use"/", and "//", and "my:"
many thanx!
 
G

Greg Collins [InfoPath MVP]

the "my:" is called a namespace prefix. It is essential. It is part of the name of the node.

"myFields" is entirely different than "my:myFields"... just as "yo:myFields" would be different.

The "/" is just fine in your scenario... no need to use "//".
 

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