小编Pav*_*l K的帖子

XPath:获取子节点包含属性的节点

假设我有以下XML:

<book category="CLASSICS">
  <title lang="it">Purgatorio</title>
  <author>Dante Alighieri</author>
  <year>1308</year>
  <price>30.00</price>
</book>

<book category="CLASSICS">
  <title lang="it">Inferno</title>
  <author>Dante Alighieri</author>
  <year>1308</year>
  <price>30.00</price>
</book>

<book category="CHILDREN">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

<book category="WEB">
  <title lang="en">XQuery Kick Start</title>
  <author>James McGovern</author>
  <author>Per Bothner</author>
  <author>Kurt Cagle</author>
  <author>James Linn</author>
  <author>Vaidyanathan Nagarajan</author>
  <year>2003</year>
  <price>49.99</price>
</book>

<book category="WEB">
  <title lang="en">Learning XML</title>
  <author>Erik T. Ray</author>
  <year>2003</year>
  <price>39.95</price>
</book>
Run Code Online (Sandbox Code Playgroud)

我想做一个xpath,它可以获取所有具有标题节点且语言属性为"it"的书节点.

我的尝试看起来像这样:

//book[title[@lang='it']]

但那没用.我希望得到回节点:

<book category="CLASSICS">
  <title lang="it">Purgatorio</title>
  <author>Dante Alighieri</author>
  <year>1308</year>
  <price>30.00</price>
</book>

<book category="CLASSICS">
  <title lang="it">Inferno</title>
  <author>Dante Alighieri</author>
  <year>1308</year> …
Run Code Online (Sandbox Code Playgroud)

xml xpath

106
推荐指数
3
解决办法
13万
查看次数

SQL Server(localdb)\ v11.0解释

我正在遵循Code First到现有数据库教程,并注意到它建议连接到(localdb)\v11.0学习目的.我尝试使用我的SQL Management Studio连接到它,它工作正常.但是当我恢复数据库备份时,它[DatabaseName].mdf在我的用户目录中创建了一个文件.

我很惊讶并有以下问题:

  1. 什么是(localdb)\v11.0?它使用我的SQL Express还是SQL Compact?
  2. 它是否仅支持存储在.mdf文件中的数据库?
  3. 除了用户的文件夹之外,如何指定还原路径?
  4. 它的一般用途是什么(仅用于学习目的)?
  5. 在哪里可以找到有关此类数据库的更多信息?

sql-server ssms localdb

72
推荐指数
1
解决办法
7万
查看次数

SqlConnection.CacheConnectionStringProperties()的.NET代码中的NullReferenceException

我面临着非常奇怪的问题.鉴于以下代码:

static void Main()
{
    var c = new System.Data.SqlClient.SqlConnection();

    c.ConnectionString = "Data Source=SOME_NAME;Initial Catalog=SOME_DB;Integrated Security=True";
    c.ConnectionString = ""; //null also triggers exception

    Console.WriteLine("Success");
}
Run Code Online (Sandbox Code Playgroud)

它运行良好很长一段时间,但在最新版本的Windows 10(1803)上有.NET版本4.7.03056版本461808(似乎是4.7.2)它崩溃了以下异常:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Data.SqlClient.SqlConnection.CacheConnectionStringProperties()
   at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
   at TestCacheConnectionStringProperties.Program.Main()
Run Code Online (Sandbox Code Playgroud)

这会在第二个任务中崩溃,如果我删除它的任何分配ConnectionString工作正常.

我查看了源代码并没有找到NullReferenceException可能发生的地方(但是.NET Framework 4.7.1似乎是源代码因此可能会改变).

现在问题是 - 导致这个问题的原因是什么?这是一个.NET错误吗?如果是 - 如何解决?

更新:根据评论 - 非常感谢伙计们 - 问题是由这些线引起的(反编译):

private void CacheConnectionStringProperties()
{
  SqlConnectionString connectionOptions = this.ConnectionOptions as SqlConnectionString;
  if (connectionOptions != …
Run Code Online (Sandbox Code Playgroud)

.net c# sqlconnection .net-4.7.2

14
推荐指数
1
解决办法
1046
查看次数

"无法同时分析32位和64位应用程序"错误

我正在Visual Studio 2012中使用"分析" - >"启动性能向导..."启动ASP.NET MVC 3项目的性能分析器,然后选择"Instrumentation"并选择我的项目(因为我需要测量定时并确定最长的函数调用).

但这会给出错误消息

It is not possible to profile 32-bit and 64-bit applications at the same time

并且分析过程终止.我试图将平台目标更改为x86,x64,任何CPU,但这没有帮助.什么可能导致这样的错误,我该如何解决?

asp.net-mvc profiling visual-studio asp.net-mvc-3 visual-studio-2012

8
推荐指数
1
解决办法
2919
查看次数

方括号[]语法在WiX中意味着什么

我正在使用WiX工具集和使用手册为IIS网站创建安装程序.我遇到了以下语法

<iis:WebSite Id="DemoWebsiteWebsite" Description='Demo Website' Directory='INSTALLFOLDER' AutoStart='yes' StartOnInstall='yes'>
  <iis:WebAddress Id="AllUnassigned" Port="80" />
  <iis:WebApplication Id="DemoWebsiteApplication" Name="[DemoWebsiteWebsite][WEBSITE_ID]" WebAppPool="DemoWebsiteAppPool"></iis:WebApplication>
</iis:WebSite>
Run Code Online (Sandbox Code Playgroud)

我对[]语法和网站ID的使用方式感到困惑.我需要使用用户输入的一些自定义值.所以我有以下问题:

  1. 什么是[]语法维克斯是什么意思?它与$()用于访问定义值的语法有何关联?
  2. []像这里一样,两个人是否有任何额外的意义[DemoWebsiteWebsite][WEBSITE_ID]
  3. 为什么在[DemoWebsiteWebsite]表达式中使用WebSite Id ?这只是一个巧合或命名惯例吗?
  4. 内部使用的允许值是[]多少?他们有什么样的清单吗?
  5. 我在哪里可以找到有关此语法及其用于的案例的其他信息?

iis windows-installer wix

4
推荐指数
1
解决办法
2638
查看次数

从Bitmap类创建.bmp图像文件

我创建了一个使用套接字的应用程序,客户端在其中接收图像并将图像数据存储在Bitmap类中....

任何人都可以告诉我如何从这个Bitmap对象创建一个名为myimage.pngmyimage.bmp的文件

String base64Code = dataInputStream.readUTF();
byte[] decodedString = null;
decodedString = Base64.decode(base64Code);
Bitmap bitmap = BitmapFactory.decodeByteArray(decodedString, 0,decodedString.length);
Run Code Online (Sandbox Code Playgroud)

java png android bitmap bmp

3
推荐指数
1
解决办法
6599
查看次数