Traversing Nodes using InfoPath Managed Code - Help with Syntax!

J

Jer

Sorry, I've been looking for quick references, but couldn't yet.
Can someone help me? Can someone recommend a site?

My problem is i dunno how this logic goes in infopath managed code using the
IXMLDOM

for example my form generates an XML. My form takes orders, for example, and
the form was able to capture 2 line items(order items). XML looks like
something like this:

<my:group6>
<my:item_code>3290</my:item_code>
<my:item_desc>Pencil</my:item_desc>
<my:item_price>493.33</my:item_price>
</my:group6>
<my:group6>
<my:item_code>3293</my:item_code>
<my:item_desc>Pen</my:item_desc>
<my:item_price>34.40</my:item_price>
</my:group6>

How i get those fields?? Supposedly, I'll pass those fields to an SQL INSERT
so I need to get those fields!

sorry i'm just kinda starting with InfoPath and XML!
 
R

Rick Severson [MSFT]

Using managed code, C# for this example, you could do something like

IXMLDOMNode myNodeList = thisXDocument.DOM.selectNodes("//my:group6);

this would give you, according to your example, a myNodeList of 2 elements.
From there, you could loop through each of the nodes to get the child nodes.
Something like

if ((myNodeList != null) && (myNodeList.length != 0))
{
for each (IXMLDOMNode mySingleNode in myNodeList)
{
thisXDocument.UI.Alert(mySingleNode.text);
}
}
 

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