We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

How to read custom XML data in Word document using Aspose.Words REST API?

Hello, I’m new to the aspose community. I have docx with custom xml and content controls. I need to extract certain fields from the custom xml inside the docx. Currently, I’m unzipping docx and then finding and reading the item#.xml file from the customXml folder. Is there a cleaner way to do this, through the aspose words cloud API?

@thebirdmanloves

You may use GetFields API method to read the fields from a Word document. Please check the following documentation for more details. Hopefully, it will help you to accomplish the task.

Thanks @tilal.ahmad. This gets me a date field that sits at the top of the doc, but not the content controls.

I also tried get document properties

const request = new GetDocumentPropertiesRequest();
request.name = fileName;
// Calling API function
wordsApi.getDocumentProperties(request)   

This gets me a list of custom properties that are used in the content controls, and query the customXml data, but not the customXml data itself.

e.g.
{

                "link": {

                    "href": "https://api.aspose.cloud/v4.0/words/example.docx/documentProperties/XPathClientHasGIAOnly",

                    "rel": "self"

                },

                "builtIn": false,

                "name": "XPathClientHasGIAOnly",

                "value": "(rd/param[pn='sippChargesChanged' and ds='1']/pv = 'N') and (rd/param[pn='isaChargesChanged' and ds='1']/pv = 'N') and (rd/param[pn='giaChargesChanged' and ds='1']/pv = 'Y')"

            }

Can you think of anything else that I could try from the cloud APIs?

@thebirdmanloves

Please share your sample Word document with custom XML and content controls along with expected output. It will help us to understand your requirement exactly and guide you.

@tilal.ahmad here’s an example from my test env. NB101 - Welcome Email Output - CA_2021Jul15.164028.177.docx (46.5 KB)

When I extract this docx to a folder, the customXml sub-folder has an item1.xml file, containing the data that I’d like to extract.

Is there a way to extract this data through the cloud API? Currently, I’m running a separate script that unzips and then reads the xml, instead.

@thebirdmanloves

Thanks for sharing the sample document. Currently, Aspose.Words Cloud does not support reading customXML data. We have logged a ticket WORDSCLOUD-1691 for the feature implementation. We will notify you as soon as it is resolved.

1 Like

The issues you have found earlier (filed as WORDSCLOUD-1691) have been fixed in this update. This message was posted using Bugs notification tool by Ivanov_John