Quick Hit: Binabasa ang InfoPath XML Direkta Mula sa isang SPListItem sa SharePoint

I’m been working on a project where I need to extract attachments from an InfoPath form. There are some good resources for parsing InfoPath forms (na lamang ang XML file, kaya talagang medyo madali).

Habang ako ay pagbuo up ang proyekto, I started by downloading an InfoPath form and saving it to my local hard drive. My c# code was reading directly from that instance. Gayunman, the InfoPath forms are really living inside a SharePoint forms library. I did a little half hearted searching to find out how to read it directly from the library and almost gave up, in which case I would have saved the form to a local temp directory and read it from there. Gayunman, there’s no need to go through those hoops as you can read it directly from the library. This little snippet shows how:

/// Class kahulugan bagay-bagay dito, kasama:
pribado SPFile mySharePointFile; /* Bahagi ng isang SPList */
// Higit pang code dito napupunta at sa loob ng isang pamamaraan ng klase mayroon kami:
XmlTextReader textReader;
textReader = bago XmlTextReader(mySharePointFile.OpenBinaryStream());

textReader.WhitespaceHandling = WhitespaceHandling.Wala;

textReader.Read();

// Kung ang node ay may halaga

habang (textReader.Read())
{

… and so on and so forth …

Sila key bit sa itaas ay na maaari naming basahin ang InfoPath nang direkta sa pamamagitan ng OpenBinaryStream() method call on the SPFile as a parameter to the constructor on XmlTextReader. It works great.

</dulo>

Mag-subscribe sa aking blog.

Sundin ako sa Twitter sa http://www.twitter.com/pagalvin

Technorati Tags:

Isa naisip sa "Quick Hit: Binabasa ang InfoPath XML Direkta Mula sa isang SPListItem sa SharePoint

  1. nesreen

    hi,
    I need help in this , I have sharepoint 2007 site and infopath with a repeating table , what I need to do is once the form is saved to the sharepoint forms library I need to loop and save the data to a list using SP form library event handler.

    Any help is really appreciated.

    Salamat

    Sumagot

-Iwan ng sagot

Ang iyong email address ay hindi nai-publish. Mga kinakailangang patlang ay minarkahan *