Hello,
I have an InfoPath form and I want to iterate through all the nodes
programmatically and
retrieve the node name, value, and the data type.
For example, my layout looks like this:
myFields
firstname
lastname
address1
address2
city
state
zip
what I have is:
var rootNode = XDocument.DOM.selectSingleNode("/my:myFields");
var oNodeList = rootNode.childNodes;
var item;
var value;
objBox.Alert("Root/Child Node Length: " + oNodeList.length);
for (var i = 0; i < oNodeList.length; i++) {
item = oNodeList.item(i);
objBox.Alert(item.text);
}
while I can get the name and value of the node, but I can't seem to get the
data type of the nodes.
Not only that, but oNodeList.length is 14. Does anyone know why?
thanks
Andrew Watt [MVP - InfoPath] - 16 Nov 2004 13:11 GMT
>Hello,
>
[quoted text clipped - 33 lines]
>
>thanks
Chris,
I assume that your oNodeList.length issue is because you have nodes
which contain only whitespace, as well as the nodes you expect to be
there.
Andrew Watt
MVP - InfoPath
Greg Collins [InfoPath MVP] - 16 Nov 2004 21:54 GMT
Have you tried using selectNodes() instead of selectSingleNode(), and then using a while statement and .nextNode() instead of a for statement and .length?

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Hello,
I have an InfoPath form and I want to iterate through all the nodes
programmatically and
retrieve the node name, value, and the data type.
For example, my layout looks like this:
myFields
firstname
lastname
address1
address2
city
state
zip
what I have is:
var rootNode = XDocument.DOM.selectSingleNode("/my:myFields");
var oNodeList = rootNode.childNodes;
var item;
var value;
objBox.Alert("Root/Child Node Length: " + oNodeList.length);
for (var i = 0; i < oNodeList.length; i++) {
item = oNodeList.item(i);
objBox.Alert(item.text);
}
while I can get the name and value of the node, but I can't seem to get the
data type of the nodes.
Not only that, but oNodeList.length is 14. Does anyone know why?
thanks
potpourri - 17 Apr 2005 10:52 GMT
same problem arises.
i can't seem to detect the node data type other than "string".
other than that, it will be regarded as "null".
does anyone know how to recognize other data type, like image, rich
text, and date/time ?
thanks :)
--
potpourri