Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / April 2005

Tip: Looking for answers? Try searching our database.

Iterating Through InfoPath XML Nodes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 16 Nov 2004 00:59 GMT
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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.