C# sqlserver2005中的XML查询
我正在运行的查询运行不正常,以下是我的代码:C# sqlserver2005中的XML查询,c#,mysql,sql,sql-server,xml,C#,Mysql,Sql,Sql Server,Xml,我正在运行的查询运行不正常,以下是我的代码: select a.id, a.userid, c.firstname + ' ' + c.lastname AS Name, a.objectid, a.settings, CAST(settings as XML).exist('property[@name=''colFirstChoiceVendorPaymentTerms'']') as first, CAST(settings as XML).exist('property[@name="
select a.id, a.userid, c.firstname + ' ' + c.lastname AS Name, a.objectid, a.settings,
CAST(settings as XML).exist('property[@name=''colFirstChoiceVendorPaymentTerms'']') as first,
CAST(settings as XML).exist('property[@name="colSecondChoiceVendorPaymentTerms"]//property[@name=''Visible'' and text()=''true'']') as second,
CAST(settings as XML).exist('property[@name="colThirdChoiceVendorPaymentTerms"]//property[@name=''Visible'' and text()=''true'']') as third
FROM wcukopera05.vstx.dbo.screenlayout a
join wcuksql01.hrsystem.dbo.person c
on a.UserId=c.Id
where a.objectid = 'gridViewCustomerCurrentRatesCosts'
我有一段很长的XML,我想检查XML中是否存在某些属性,如(colThirdChoiceVendorPaymentTerms),并查看可见性是否为真
此时,我的代码返回所有正确的列,但列“first”、“second”和“third”的值都返回0。但是他们中的一些应该返回1
我不明白为什么他们都返回0
我在这里上传了XML:txt.do/dev1您将看到colFirstChoiceVendorPaymentTerms和colSecondChoiceVendorPaymentTerms的可见性设置为true。但Colthird ChoiceVendorPaymentTerms不可见。这就是我要检查的。是否存在可见性和列
再次感谢你的帮助
'property[@name="colSecondChoiceVendorPaymentTerms"]//property[@name=''Visible'' and text()=''true'']'
我不明白为什么他们都返回0
@name
与节点值进行比较'//property[.="colSecondChoiceVendorPaymentTerms"]/../property[@name=''Visible'' and text()=''true'']'
或者您无法使用深度搜索并使用value来获取节点的值@name=“Visible”
settings.value('(/XtraSerializer/property/property[property/@name="Name" and property = "colSecondChoiceVendorPaymentTerms"]/property[@name = "Visible"])[1]', 'bit')