How can I get the ContentType of the CustomXmlPart?

Hi All!
The Open XML SDK contains the class CustomXmlPart. The class contains the property: public virtual string ContentType { get; }. Your class CustomXmlPart (from Aspose.Words.Markup) hasn’t same property. How can I get the ContentType of the CustomXmlPart?
Thanks!

@kim3d,

Thanks for your inquiry. Please use CustomXmlPart.Data property to get or set the XML content of this Custom XML Data Storage Part. This property gets or sets the byte array value.

I need to access to the ContentType of the CustomXmlPart, not to the Data.

@kim3d

Thanks for your inquiry. Unfortunately, Aspose.Words does not provide this feature. Could you please ZIP and attach your input Word document along with expected output content type here for our reference? We will then provide you more information on this.

Hi Tahir,

Here are the content types we are interested in.

public const string MapDocumentType = "application/lexomi+map+html+json";
public const string MasterMapDocumentType = "application/lexomi+mastermap+html+json";
public const string PartDocumentType = "application/lexomi+part+html+json";
public const string MasterPartDocumentType = "application/lexomi+masterpart+html+json";
public const string TemplateDocumentType = "application/lexomi+template+html+json"

We want to be able to select all custom xml parts that have one of these content types, and not select anything else. With Open XML SDK we would do something like this:

var customXmlParts = mainDocumentPart.GetPartsOfType().Where(p => p.ContentType == MapDocumentType
|| p.ContentType == PartDocumentType
|| p.ContentType == TemplateDocumentType
|| p.ContentType == MasterMapDocumentType
|| p.ContentType == MasterPartDocumentType).ToList();

Here is a sample document:
https://1drv.ms/w/s!AnzuIdjK5y7nlZptvP9DpyUDnCS6eA

Many thanks,
kim3d/lexomi

Same document, zipped in case there are issues with downloading it from the previous link.
https://1drv.ms/u/s!AnzuIdjK5y7nlZpvNkSu4br3hue47g

@lexomi

Thanks for sharing the detail. We have logged this feature request as WORDSNET-15882 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

We wait, Thanks!

@lexomi

Thanks for your patience. It is to inform you that we are closing the issue (WORDSNET-15882). Aspose.Words does not parse CustomXmlPart, so all the information about its type is stored inside CustomXmlPart.Data and you can get this information. You just need to parse CustomXmlPart.Data – it is simple XML.

Document doc = new Document(MyDir + "Document.docx");
CustomXmlPart part = doc.CustomXmlParts[0];
string customXmlAsString = Encoding.ASCII.GetString(part.Data);
Console.WriteLine(customXmlAsString);
<part>{
"title": "Handle",
"boxes": [],
"propertyBag": [],
"partId": "group_Tasks",
"id": "group_4dd9398c-ffe9-46de-a30a-cef3ebd9646d.json",
"documentType": "PartGroup",
"tenant": "0000",
"state": "Unchanged",
"inheritance": "Individualized",
"version": null,
"initialTimeStamp": null,
"lastModifiedTimeStamp": null
}</part>

It seems means this is PartDocumentType.

The information about ContentType of the CustomXmlParts are contained in the another file into the MS Word doc - in the [Content_Types].xml and looks as see please in attache file.[Content_Types].xml.zip (589 Bytes)

You need to parse this file and give information as this doing Open XML SDK. In this case other companies can separate CustomXmlParts that they add into the MS Word file.

@lexomi

Thanks for sharing the detail. We have logged this information in our issue tracking system. Once our product team completes the analysis of this issue. We will then provide you more information on this. We apologize for your inconvenience.

@tahir.manzoor
Please contact with me by my email from my profile, I may give more details of the problem. Many companies don’t use your product, because your product isn’t work with the CustomXmlParts as good as the OpenXML SDK.

@kim3d,

Thanks for your inquiry. We have closed the issue (WORDSNET-15882). Please note that Aspose.Words mimics the same behavior as MS Word does.

We do not need to parse the content type of Custom XML Data Storage Part because it is always “application/xml”. Please try to open/save your document using MS Word and check the output [Content_Types].xml. You will see that all Custom XML Data Storage Part with content type which is not equals “application/xml” were removed from the document.

kim3d:

Please contact with me by my email from my profile

We only provide support via forums. Please post your queries in Aspose.Words’ forum.

@tahir.manzoor
I created the MS Word doc, added some our CustomXmlParts with our ContentTypes by the OpenXml SDK and opened/saved the MS Word doc by the MS Word 2016. And I see that the ContentType these CustomXmlParts stayed same in the [Content_Types].xml And I see other CustomXmlParts with other ContentType, not only “application/xml”! See: https://www.screencast.com/t/SOtaGkSkL
https://www.screencast.com/t/oC5UUl7d
You may not add support the ContentType in the your CustomXmlPart class and we will be use OpenXml SDK vice your product - Aspose.Word.
And could buy your product. And other companies who use CustomXmlParts, too.

@kim3d,

Thanks for your inquiry. We have re-saved the shared document using MS Word 2016 and [Content_Types].xml has changed. Please check the attached document. re-saved by ms word.zip (23.0 KB)

If you are using different document, please share it here for further testing.

@tahir.manzoor
You are right.