Free Support Forum - aspose.com

selectNodes() XPath question

What attributes can I use with the selectNodes() XPath query expression?



For example, can I do something like this to get the Run Nodes with text “hello world”?

NodeList nodes = revisionDoc.selectNodes("//Run[@Text=‘hello world’");



Or something like this to select all runs with a style of ‘Heading 2’

NodeList nodes = revisionDoc.selectNodes("//Run[@Style=‘Heading 2’");



Thanks!




These compile and run but don’t return any nodes:

nodes = revisionDoc.selectNodes("//Run[Text=‘revision’]");

nodes = revisionDoc.selectNodes("//Run[Style=‘Normal’]");



Is there any documentation or examples for this?

Thanks


Only element names are supported in XPath queries in Aspose.Words at the moment. I was sure it was mentioned in the documentation, but I could not find this, will fix. Sorry for that.

"//Run" will work.

You can also look at using CompositeNode.GetChildNodes instead.