通过c#中的xapth获取不匹配的记录 [英] Get unmatched records through xapth in c#

查看:68
本文介绍了通过c#中的xapth获取不匹配的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我如何使用  " not"   或  "!"   sign给定的xpath表达式中的
不匹配的记录

我的代码:

var varItem = from x in xDocFile.XPathSelectElements("//ext-link[@*[name()='xlink:href' and (.=concat('http://', parent::*) or .=concat('https://', parent::*))] or @*[name()='xlink:href']=text()]") select x;


例如:

<ext-link xlink:href="http://effectivehealthcare.ahrq.gov/" ext-link type="uri">effectivehealthcare.adfgsdfgsdfghrq.gov/</ext-link>

< ext-link xlink:href = " http://effectivehealthcardfddfde.ahrq.gov/" ext-link-type = " uri" > effectivehealthcare.ahrq.gov / < / ext-link>

<ext-link xlink:href="http://effectivehealthcardfddfde.ahrq.gov/" ext-link-type="uri">effectivehealthcare.ahrq.gov/</ext-link>

< ext-link xlink:href = " https:/www.one/" ext-link-type = " uri" > https://www.one/ < / ext-link>

<ext-link xlink:href="https:/www.one/" ext-link-type="uri">https://www.one/</ext-link>

< ext-link xlink:href = " https:// three /" ext-link-type = " uri" >< / ext-link>

<ext-link xlink:href="https://three/" ext-link-type="uri"></ext-link>

< ext-link xlink:href = " https://www.two/" ext-link-type = " uri" > http://www.two/ < / ext-link>

<ext-link xlink:href="https://www.two/" ext-link-type="uri">http://www.two/</ext-link>

< ext-link xlink:href = " http://effectivehealthcare.ahrq.gov/" ext-link-type = " uri" > effectivehealthcare.ahrq.gov / < / ext-link>

<ext-link xlink:href="http://effectivehealthcare.ahrq.gov/" ext-link-type="uri">effectivehealthcare.ahrq.gov/</ext-link>

< ext-link xlink:href = " http://www.one/" ext-link-type = " uri" > www.one / < / ext-link>

<ext-link xlink:href="http://www.one/" ext-link-type="uri">www.one/</ext-link>

< ext-link xlink:href = " https:// three /" ext-link-type = " uri" > 三/ < / ext-link>

<ext-link xlink:href="https://three/" ext-link-type="uri">three/</ext-link>

< ext-link xlink:href = " https://www.two/" ext-link-type = " uri" > https://www.two/ < / ext-link>

<ext-link xlink:href="https://www.two/" ext-link-type="uri">https://www.two/</ext-link>




我的输出将如下所示:

<ext-link xlink:href="http://effectivehealthcare.ahrq.gov/" ext-link-type="uri">effectivehealthcare.adfgsdfgsdfghrq.gov/</ext-link>

< ext-link xlink:href = " http://effectivehealthcardfddfde.ahrq.gov/" ext-link-type = " uri" > effectivehealthcare.ahrq.gov / < / ext-link>

<ext-link xlink:href="http://effectivehealthcardfddfde.ahrq.gov/" ext-link-type="uri">effectivehealthcare.ahrq.gov/</ext-link>

< ext-link xlink:href = " https:/www.one/" ext-link-type = " uri" > https://www.one/ < / ext-link>

<ext-link xlink:href="https:/www.one/" ext-link-type="uri">https://www.one/</ext-link>

< ext-link xlink:href = " https:// three /" ext-link-type = " uri" >< / ext-link>

<ext-link xlink:href="https://three/" ext-link-type="uri"></ext-link>

< ext-link xlink:href = " https://www.two/" ext-link-type = " uri" > http://www.two/ < / ext-link>

<ext-link xlink:href="https://www.two/" ext-link-type="uri">http://www.two/</ext-link>

推荐答案

嗨Soniya Singh,

Hi Soniya Singh,

感谢您发布此处。

XML Path Language是一种查询语言从XML文档中选择节点。有关详细信息,请参阅链接。
http://www.w3。 org / TR / xpath20 /

The XML Path Language, is a query language for selecting nodes from an XML document. For more details, please refer to the link. http://www.w3.org/TR/xpath20/

1. text()表示匹配任何文本节点。名称([node-set] )表示

中的第一个节点将返回此节点集。如果省略此参数,则为当前节点集将使用上下文节点。
T

"父母: :"轴包含返回上下文节点的父节点的序列,或者如果上下文节点,则包含空的

序列没有父母。

2.基于我的搜索,我在上面的文章中找不到任何与之匹配的内容。

也许这些工具不提供匹配功能。所以我建议你匹配一些你需要得到的东西,而不是剩下的不匹配内容。

想得到的东西。 &NBSP;

3。 W3C是第三个产品,您可以尝试联系他们的支持。我将把主题移到主题

3. The W3C is the third product, you can attempt to contact their support. I will move the thread to off-topic

http://www.w3。 org / Consortium / contact.html

我希望回复会对您有所帮助。 如果您的问题已经解决,请标记。

I hope the reply would be helpful to you.  If your issue has been resolved, please mark it.

如果您还有其他问题,请随时与我们联系。

If you have something else, please feel free to contact us.

最诚挚的问候,

Hart


这篇关于通过c#中的xapth获取不匹配的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆