Closed algomaster99 closed 4 years ago
I am not able to get the nodes according to the xPath I provide. I always get an empty array. When I pass as xPath, I get he first node and then I have to get nodes from there recursively (by passing ''). Example,
Office.context.document.customXmlParts.getByNamespaceAsync('accordproject.org', (res) => {
if (res.status === Office.AsyncResultStatus.Succeeded) {
console.log('xml', res.value);
res.value[0].getNodesAsync('*/*', (nodes) => {
if (nodes.status === Office.AsyncResultStatus.Succeeded) {
console.log('1',nodes.value);
nodes.value[0].getNodesAsync('*', (res) => {
if (res.status === Office.AsyncResultStatus.Succeeded) {
console.log('2', res.value);
res.value[1].getNodeValueAsync((res) => {
if (res.status === Office.AsyncResultStatus.Succeeded) {
console.log('3', res.value);
}
})
}
});
}
})
}
});
This is just for demonstration. If xPath
doesn't work, I might have to write a recursive function wherein I will get each node one by one.
Hi @algomaster99 I assigned this to one of the Word engs, but I think you might also have luck posting this question to Stack Overflow tagged [office-js] and [Word]. There's a huge developer community there willing to help!
@lindalu-MSFT I have asked the question here https://stackoverflow.com/questions/62809742/xpath-parameter-in-getnodesasync-is-not-working-as-expected.
The answer is provided from the above stackoverflow question. Closing this one.
Expected Behavior
Should have received an array of the nodes corresponding to the xPath.
Current Behavior
An empty array is being showed as the output.
Steps to Reproduce, or Live Example
Script Lab
Get node
is supposed to fetch the nodes at/AP/template
.Delete XML
will delete the customXML.Context
I need to store some values in the XML and update them whenever I update things in the document.
Your Environment