Hello,
I'm trying to figure out how I can select a specific CustomXML part from an openxml document (without using Word).
The custom xml is added to the document using a word add-in. I've used a namespace in the xml, so within the addin, I can easily retrieve the custom part again:
CustomXMLParts xmlParts = doc.CustomXMLParts.SelectByNamespace("urn:some-unique-namespace");
CustomXMLParts
doc.CustomXMLParts.SelectByNamespace(
PackagePart docPart = GetDocumentXmlPart(package); //this returns the main document part foreach (PackageRelationship docRel in docPart.GetRelationshipsByType( @http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml)) { //how do I know it's the correct one? return package.GetPart(PackUriHelper.ResolvePartUri( new Uri("/", UriKind.Relative), docRel.TargetUri)); } return null;
GetDocumentXmlPart(package); //this returns the main document part foreach (PackageRelationship docRel in docPart.GetRelationshipsByType( @http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml)) { //how do I know it's the correct one? return package.GetPart(PackUriHelper.ResolvePartUri( new Uri("/", UriKind.Relative), docRel.TargetUri)); } return null;
GetDocumentXmlPart(package); //this returns the main document part
foreach (PackageRelationship docRel in docPart.GetRelationshipsByType(
@http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml))
{
//how do I know it's the correct one?
return package.GetPart(PackUriHelper.ResolvePartUri(
new Uri("/", UriKind.Relative), docRel.TargetUri));
}
return null;
Any ideas?