none
how to read embedded .xml file from word document RRS feed

  • Question

  • hello everybody,

     

                               I have programmtically embedded a .xml file named "context.xml" in word document in the docprops folder. this is my .xml file

     

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>

    - <cx:context xmlns:cx=http://example.com cx: docid="150f7ab2-70dd-4d27-89bd-6c7c090efa1e">
      <cx: scope cx:initdata="1209543427459" cx:lastvisit="1209543427459" cx:url="http://www.freitag.de" />
      </cx:context>

    so how can unzip the word package and read this .xml file.

     

    Actually my code is

     

    Package pack = Package.Open(fName);

    Uri uri= new Uri("/docProps/context.xml", UriKind.Relative);

    PackagePart packPart = pack.GetPart(uri); // error specified part is not in the package.

    XmlDataDocument xdoc = new XmlDataDocument();

    xdoc.Load(packPart.GetStream(FileMode.Open));

    XmlNamespaceManager nsmgr = new XmlNamespaceManager(xdoc.NameTable);

    nsmgr.AddNamespace("cp", corePropertiesSchema);

    //nsmgr.AddNamespace("dc", dcPropertiesSchema);

    XmlNode xn = null;

    xn = xdoc.SelectSingleNode("cp:coreProperties/cx: docid", nsmgr);

    if (xn != null)

    tbTitle.Text = xn.InnerText;

    //xn = xdoc.SelectSingleNode("cp:coreProperties/dc:creator", nsmgr);

    //if (xn != null)

    // tbAuthor.Text = xn.InnerText;

    pack.Close();

    But iam getting a error in 3rd line. so how can i retreive a node from my .xml file inside the docProps folder 

    Thank you in advance.

    Dinesh.

    Wednesday, April 30, 2008 9:27 AM