简体   繁体   English

当我将 XML 文档加载到 Monaco 编辑器时,如何通过鼠标单击或 select 获取 XML 信息?

[英]when I load an XML document to the Monaco editor, how can I get XML information on a mouse click or select?

I need to perform various XML structure related operations on an XML document.我需要对 XML 文档执行各种 XML 结构相关操作。 I can load it into the Monaco editor and get nice syntax highlighting and various other services.我可以将它加载到 Monaco 编辑器中,并获得很好的语法突出显示和各种其他服务。 But can I get the node and tag information from a mouse click or select or KeyUp event or will I need to have an XDocument object and use the line number and column information from the editor events to synchronize?但是我可以通过鼠标单击或 select 或 KeyUp 事件获取节点和标签信息,还是需要 XDocument object 并使用编辑器事件中的行号和列信息进行同步?

I am building a Blazor client side application, with the BlazorMonaco project and setting the language to 'xml'.我正在使用 BlazorMonaco 项目构建 Blazor 客户端应用程序并将语言设置为“xml”。 Any other ideas?还有其他想法吗?

The monaco editor only comes with simple support for most languages, which is mostly syntax highlighting (and no parsing). monaco 编辑器只提供对大多数语言的简单支持,主要是语法高亮(并且没有解析)。 That means it cannot give you can syntactical information about the document content.这意味着它不能为您提供有关文档内容的语法信息。

Intstead you need to implement your own parser for XML (eg using ANTLR4 and the XML grammar ).相反,您需要为 XML 实现自己的解析器(例如,使用 ANTLR4 和XML 语法)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM