Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Reading SP lists using C#

  Asked By: Alvin    Date: Aug 02    Category: Sharepoint    Views: 4417

Does anyone know how to view data which is saved in an Infopath form
and promoted to a list? I need data that is embedded in a form's
detail group which is not promoted to the list. Using SPFileCollection
and SPListItemCollection I've found some metadata (the number of fields
in the form, for example), but I don't see the complete set of XML data
in either one. Am I overlooking a method or something?



6 Answers Found

Answer #1    Answered By: Elijah Davis     Answered On: Aug 02

Fields from the InfoPath form  that are promoted  will be available in the
SPListItem object as columns. Fields form the InfoPath form that are not
promoted must be read by reading  and parsing the InfoPath XML file that is
stored as the attachment of the SPListItem. Take a look at the following BLOG


Answer #2    Answered By: Akanksha Jain     Answered On: Aug 02

I tried SPAttachmentCollection, but SharePoint throws
an error because I am dealing with a document library, and the
SPListItem member Attachments property does not apply to document
libraries. It returns an ArgumentOutOfRangeException exception if
applied to a document library.

I also can't use XmlDocument to do a document.Load(doclocation),
because I get authentication errors. If I do this: Console.WriteLine
(oListItem.Xml.ToString()) it displays the metadata  with guids
instead of xml  tags.

Does anyone know of an InfoPath Namespace that can expose XML so I
can read it from a document library?

Answer #3    Answered By: Bhupendra Borkar     Answered On: Aug 02

why not just load the form  XML and use XQuery to grab the underlying data  that
you need?

Answer #4    Answered By: Shobhana R.     Answered On: Aug 02

The problem is I can't read the form  XML
from this document library because I can't find an object that has
the authority to read it. Any ideas?

Answer #5    Answered By: Winston Ayers     Answered On: Aug 02

Form libraries are based on Document libraries, so you need to use the
object model calls for a Document Library item instead of a generic list
item. Take a look at SPListItem.File
.file.aspx ) and SPFile
x ) which correspond to the actual contents of a document/form in a

Answer #6    Answered By: Moshe Harding     Answered On: Aug 02

I finally found  a link that explained the final piece of the problem
I was having pulling the xml  out of doicuments in a document
library. The simple answer: I needed to add "?noredirect=true" to
the end of the link, as follows:


With this simple addition to the link url, I am finally able to get
the InfoPath XML detail group  and pull the detailed financial
information in our requisitions into SQL, and then kick back and take
a vacation in Bermuda!

Here is the full story with the exact same problems I was having:

Didn't find what you were looking for? Find more on Reading SP lists using C# Or get search suggestion and latest updates.