Is it possible to get value of xml attribute and element from context?

SyntaxEditor Web Languages Add-on for WPF Forum

Posted 2 years ago by Aristo - Senior Team Leader, Petrolink Services
Version: 14.2.0610
Avatar

Hi ActiPro, I want to be able to read value of attribute and element and manipulate it via Syntax Editor. For example adding new attribute, deleting existing attribute, change attribute and element value and so on. Is it possible to get value of xml attribute and element from context? I can see hierarchies however I don't have any way to locate attribute value.

If I can't what is recommended way to get such value, as I want to avoid to reparse whole document from different mechanism (eg XmlDocument/Xml Linq/Xpath). 

Comments (1)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The context objects like IXmlAttributeContext, etc. give more info about the name of the attribute but not values or where they are.  The AST however stores offset range info for each AST node, so you could possibly use the AST to determine the offset range.  The IXmlParseData that gets returned by the parser and stored on the document has a reference to the AST and should also reference the ITextSnapshot that the AST is based on.  Use that along with the offset ranges to get raw snapshot text for things like attribute values.


Actipro Software Support

The latest build of this product (v2019.1 build 0682) was released 4 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.