如何让 XML IntelliSense 在 VS 2015 中工作?
How to get XML IntelliSense working in VS 2015?
Visual Studio 支持 XML IntelliSense for Visual Basic(它会在您键入时建议 XML 元素和属性名称)。我正在尝试使用 VS 2015 更新我几年前在 VS 2012 或 2013 中开始的项目。该项目使用 XML 并且我已设置为使用 XML IntelliSense。该项目在 VS 2015 下编译并正确运行,但 XML IntelliSense 不工作(没有建议元素名称)。
为了尝试解决问题,我创建了以下 XML 文件(在我的文档中存储为 Test.xml):
<?xml version="1.0" encoding="utf-8"?>
<Root xmlns="http://www.finetime.com">
<Parent>
<Child>Data</Child>
</Parent>
</Root>
我在单个表单 Button1
上创建了一个新的 Windows Forms 项目 Button1
并向该项目添加了以下 XML 架构(XSD 文件显示在解决方案资源管理器中):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.finetime.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.finetime.com">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="Parent">
<xs:complexType>
<xs:sequence>
<xs:element name="Child" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Form1
的代码如下所示:
Imports <xmlns:ft="http://www.finetime.com">
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim xmlPath As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "Test.xml")
Dim xmlDoc As XDocument = XDocument.Load(xmlPath)
Dim root As XElement = xmlDoc.<ft:Root>.First
Dim data As String = root.<ft:Parent>.<ft:Child>.Value
MessageBox.Show(data)
End Sub
End Class
项目编译运行,点击按钮时在MessageBox
中显示"Data",但没有XML字补全。
例如,当我键入 Dim root As XElement = xmlDoc.<ft:
时,我希望显示 XML 元素名称的选择以完成语句,但没有出现。我错过了一步吗?
在 Roslyn 重建 (VS2015) 下,VB 似乎没有包含 XML Intellisense。这记录在 MS Connect 票证中:https://connect.microsoft.com/VisualStudio/feedback/details/1085407/intellisense-not-working-with-xml-to-schema.
Posted by Kevin [MSFT] on 1/14/2015 at 9:43 AM Hi,
Thanks for the feedback. Unfortunately, this is one of the corners of
the VB IDE experience that has not yet been re-built as part of the
Roslyn project. We have a workitem on our backlog to consider
implementing this in the future.
-- Kevin Pilch-Bisson Visual Studio Managed Languages
Visual Studio 支持 XML IntelliSense for Visual Basic(它会在您键入时建议 XML 元素和属性名称)。我正在尝试使用 VS 2015 更新我几年前在 VS 2012 或 2013 中开始的项目。该项目使用 XML 并且我已设置为使用 XML IntelliSense。该项目在 VS 2015 下编译并正确运行,但 XML IntelliSense 不工作(没有建议元素名称)。
为了尝试解决问题,我创建了以下 XML 文件(在我的文档中存储为 Test.xml):
<?xml version="1.0" encoding="utf-8"?>
<Root xmlns="http://www.finetime.com">
<Parent>
<Child>Data</Child>
</Parent>
</Root>
我在单个表单 Button1
上创建了一个新的 Windows Forms 项目 Button1
并向该项目添加了以下 XML 架构(XSD 文件显示在解决方案资源管理器中):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.finetime.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.finetime.com">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="Parent">
<xs:complexType>
<xs:sequence>
<xs:element name="Child" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Form1
的代码如下所示:
Imports <xmlns:ft="http://www.finetime.com">
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim xmlPath As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "Test.xml")
Dim xmlDoc As XDocument = XDocument.Load(xmlPath)
Dim root As XElement = xmlDoc.<ft:Root>.First
Dim data As String = root.<ft:Parent>.<ft:Child>.Value
MessageBox.Show(data)
End Sub
End Class
项目编译运行,点击按钮时在MessageBox
中显示"Data",但没有XML字补全。
例如,当我键入 Dim root As XElement = xmlDoc.<ft:
时,我希望显示 XML 元素名称的选择以完成语句,但没有出现。我错过了一步吗?
在 Roslyn 重建 (VS2015) 下,VB 似乎没有包含 XML Intellisense。这记录在 MS Connect 票证中:https://connect.microsoft.com/VisualStudio/feedback/details/1085407/intellisense-not-working-with-xml-to-schema.
Posted by Kevin [MSFT] on 1/14/2015 at 9:43 AM Hi,
Thanks for the feedback. Unfortunately, this is one of the corners of the VB IDE experience that has not yet been re-built as part of the Roslyn project. We have a workitem on our backlog to consider implementing this in the future.
-- Kevin Pilch-Bisson Visual Studio Managed Languages