×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

XPathNodeIterator move.next method is not looping through each single value???

XPathNodeIterator move.next method is not looping through each single value???

XPathNodeIterator move.next method is not looping through each single value???

(OP)

CODE --> C#

//update list item

 string siteUrl = http://sp-app/dev;
ClientContext clientContext = new ClientContext(siteUrl);

 list oList = clientContext.Web.Lists.GetByTitle("Item Inventory");

PathNavigator root = MainDataSource.CreateNavigator();

 

XPathNodeIterator iter = root.Select("/my:myFields/my:group1", NamespaceManager);

 

while (iter.MoveNext())

 {

string value = iter.Current.Value;

 

int id;

 

Int32.TryParse(value, out id);



ListItem oListItem = oList.GetItemById(id);



 oListItem[

"Title"] = field1;

 oListItem.Update(); 

I figured out what is wrong but don't know how to fix it. When I select more than one checkboxes, the xPathNodeiterator concates all the values together instead of looping through each value individually. For instance,

select check box 1

select Checkbox 2

value = 12 my goal is to have a loop

value =1 than

value = 2.

select checkbox 1

value = 1

Can somone tell me why this isnt looping thorugh each single value? and why is it appending them all into one value? this will solve the problem. thanks

RE: XPathNodeIterator move.next method is not looping through each single value???

Is group1 the GroupBox that contains your checkboxes? If it is, you should be selecting by checkbox instead.

RE: XPathNodeIterator move.next method is not looping through each single value???

(OP)
i tried. that gives me another error

CODE -->

//create a xPathnav
            XPathNavigator listBox = MainDataSource.CreateNavigator();

            //create a xPathIterator
            XPathNodeIterator iter = listBox.Select("/my:myFields/my:group1/my:field3", NamespaceManager);

         
            //foreach (XPathNavigator iters in iter)
                //Console.WriteLine(iters.Value);


            while (iter.MoveNext())
            {
                //string value = iters.Current.Value;
                //XPathNodeIterator newIter = iter.Current.SelectDescendants(XPathNodeType.Element, false);
         
                    string value = iter.Current.Value;
                    string siteUrl = "http://sp-app/dev";
                    ClientContext clientContext = new ClientContext(siteUrl);
                    List oList = clientContext.Web.Lists.GetByTitle("Item Inventory");

                    ListItem oListItem = oList.GetItemById(value);

                    oListItem["Title"] = "hahaha";
                    oListItem.Update();
                    clientContext.ExecuteQuery();
         
                   } 

the error is on this line
ListItem oListItem = oList.GetItemById(value);--------{"The 'sId' argument is invalid."} The value is nothing.

RE: XPathNodeIterator move.next method is not looping through each single value???

Have you stepped through this code with a debugger? It sounds like the string "value" doesn't have the content you are expecting.

RE: XPathNodeIterator move.next method is not looping through each single value???

(OP)
I understand that much PDMAdmin. That what i said by the value is nothing. When I use this XPathNodeIterator iter = listBox.Select("/my:myFields/my:group1/my:field3", NamespaceManager);
, I get nothing for the value.

When I use this XPathNodeIterator iter = root.Select("/my:myFields/my:group1", NamespaceManager, i get the group of elements and therfore it concates all the values together and I thought the iter.move method would iterate each single value but it doesnt. I just do not know what the syntax or code is to select each single checkbox value and loop through each inidvidually.

RE: XPathNodeIterator move.next method is not looping through each single value???

Can you post your XML schema?

RE: XPathNodeIterator move.next method is not looping through each single value???

(OP)

CODE -->

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.27" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Users\spadmin\AppData\Local\Microsoft\InfoPath\Designer3\c599af3827794388\manifest.xsf" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes" xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields" xmlns:q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-02-13T18:23:25" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
	<my:field1></my:field1>
	<my:field2></my:field2>
	<my:group1>
		<my:field3></my:field3>
	</my:group1>
	<my:txtEval></my:txtEval>
	<my:group2>
		<my:group3>
			<my:field5></my:field5>
		</my:group3>
	</my:group2>
	<my:selectAll>false</my:selectAll>
</my:myFields> 

RE: XPathNodeIterator move.next method is not looping through each single value???

Your XML selection looks okay to me. Without seeing more of your code, it's hard for me to make a specific recommendation. One idea that comes to mind is to go back to selecting by group, getting the "value=12" scenario you were seeing before. You could then do something like this:

if(value.Contains("1"))
// Process checkbox 1
if(value.Contains("2"))
// Process checkbox 2

RE: XPathNodeIterator move.next method is not looping through each single value???

(OP)
I have about 40 checkboxes. That would be to many if statements. what other code do you need? Can you help me revise this to use For Each statement loop. instead of iter.movenext. Thats another way it may work

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close