gpt4 book ai didi

xml - 如何让 XML IntelliSense 在 VS 2015 中工作?

转载 作者:数据小太阳 更新时间:2023-10-29 02:08:02 25 4
gpt4 key购买 nike

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>

我用一个按钮创建了一个新的 Windows 窗体项目 Button1在单一表格上 Form1并将以下 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中的“数据”单击按钮时,但不会发生 XML 单词完成。

例如,当我输入 Dim root As XElement = xmlDoc.<ft:我希望显示 XML 元素名称的选择以完成语句,但什么也没有出现。我错过了一步吗?

最佳答案

在 Roslyn 重建 (VS2015) 下,XML Intellisense 似乎未包含在 VB 中。这记录在 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

关于xml - 如何让 XML IntelliSense 在 VS 2015 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34272961/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com