Iterating Through InfoPath XML Nodes

C

Chris

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
 
A

Andrew Watt [MVP - InfoPath]

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

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
 
P

potpourri

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 :)
 

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