读取包含搜索词的xml标签。 [英] Read xml tags containing search term.

查看:77
本文介绍了读取包含搜索词的xml标签。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有xml文件,我想把它读作以下规则


  1. 检查xml文件中的字符串。
  2. 读取最近的标签名称  < queryItem> ...............< / queryItem>  那
    将stringn包含在第1点。
  3. 返回名称标签的名称值  < name
    locale =" zh"> **此名称**< / name>
    在queryItem标记内。
  4. < li style ="margin:0px;填充:0像素;边框:0像素;自动换行:break-word">读取名称最近的标签  < querySubject> ...............< / querySubject>  
    将字符串括起来点1.并将其名称值返回为第3点。



我已经通过阅读行(vbscript)尝试了很多 
= contents.readline
并从行获取queryItem和querySubject标签。但由于返回的行包含许多其他queryItems和querySubjects所以我的readline无法获取我到包含字符串的确切标签。



任何建议实现这个逻辑?

解决方案

< blockquote>

你好,


你可以使用Linq to XML API实现所有逻辑。


没有你的XML就不可能为您提供满足您需求的代码示例。


I have xml file and I want to read it as following rule

  1. Check for a string in xml file.
  2. Read the nearest tag with name <queryItem>...............</queryItem> that encloses the stringn in point 1.
  3. Return the name value of name tag <name locale="en">**This Name**</name>within queryItem tag.
  4. Read the nearest tag with name <querySubject>...............</querySubject> that encloses the string in point 1. and return its name value as point 3.

I have already tried a lot by reading line(vbscript) Line = contents.readlineand getting queryItem and querySubject tags from line. But as the Line returned contains many other queryItems and querySubjects so My readline fails to get me to the exact tags containing string.

Any suggestion to implement this logic?

解决方案

Hi there,

You can implement all your logic by using Linq to XML API.

Without having your XML it is impossible to provide you a sample of the code for your needs.


这篇关于读取包含搜索词的xml标签。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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