/// <summary>
/// Get Coma delimitated value set form InfoPath form item
/// </summary>
/// <param
name="url">Site URL for the
InfoPath form library</param>
/// <param
name="InfoPathFormLibraryName">InfoPath
form library Name</param>
/// <param
name="itemID">InfoPath form
library item</param>
/// <returns>Coma delimitated value set</returns>
private static string ReadFromInfoPathForm(string
url, string InfoPathFormLibraryName, int itemID)
{
string
output = string.Empty;
//Open
site which contains InfoPath form library
using
(SPSite site = new
SPSite(url))
{
using
(SPWeb web = site.OpenWeb())
{
//Open
InfoPath form library
SPList
list = web.Lists[InfoPathFormLibraryName];
//Get
Correspondent list item
SPListItem
item = list.GetItemById(itemID);
//Read
InfoPath from
SPFile infoPathFrom = item.File;
//Get
xml Transformation
XmlTextReader infoPathform = new XmlTextReader(infoPathFrom.OpenBinaryStream());
infoPathform.WhitespaceHandling = WhitespaceHandling.None;
string
nodeKey = string.Empty;
//Read
each node in InfoPath
while
(infoPathform.Read())
{
if (!string.IsNullOrEmpty(infoPathform.Value))
{
switch (nodeKey)
{
#region Assigning values
case "my:txtFistName":
case "my:txtLastName":
case "my:txtEmailAddress":
output = string.Concat(output,
nodeKey.Length > 3 ? nodeKey.Substring(3) : nodeKey, "=", infoPathform.Value, ",\n");
break;
#endregion
}
}
nodeKey =
infoPathform.Name;
}
}
}
return
output;
}
No comments:
Post a Comment