Visual Studio支持 XML IntelliSense for Visual Basic(它在您键入时建议使用XML元素和属性名称).我试图使用VS 2015更新我几年前在VS 2012或2013中开始的项目.该项目使用XML,我已经设置使用XML IntelliSen
为了尝试解决问题,我创建了以下XML文件(在My Documents中存储为Test.xml):
<?xml version="1.0" encoding="utf-8"?> <Root xmlns="http://www.finetime.com"> <Parent> <Child>Data</Child> </Parent> </Root>
我在单个表单Form1上创建了一个带有单个按钮Button1的新Windows窗体项目,并将以下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