- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试以编程方式解析 Atom 提要。我将原子 XML 下载为字符串。我可以将 XML 加载到 XmlDocument
中。但是,我无法使用 XPath 遍历文档。每当我尝试时,我都会得到 null
。
我一直在使用这个 Atom 提要作为测试:http://steve-yegge.blogspot.com/feeds/posts/default
调用 SelectSingleNode()
总是返回 null
,除非我使用“/
”。这是我现在正在尝试的:
using (WebClient wc = new WebClient())
{
string xml = wc.DownloadString("http://steve-yegge.blogspot.com/feeds/posts/default");
XmlNamespaceManager nsMngr = new XmlNamespaceManager(new NameTable());
nsMngr.AddNamespace(string.Empty, "http://www.w3.org/2005/Atom");
nsMngr.AddNamespace("app", "http://purl.org/atom/app#");
XmlDocument atom = new XmlDocument();
atom.LoadXml(xml);
XmlNode node = atom.SelectSingleNode("//entry/link/app:edited", nsMngr);
}
我认为这可能是因为我的 XPath,所以我也尝试了根节点的简单查询,因为我知道根节点应该可以工作:
// I've tried both with & without the nsMngr declared above
XmlNode node = atom.SelectSingleNode("/feed");
无论我做什么,它似乎都无法选择任何东西。显然我错过了一些东西,我只是想不通是什么。我需要做什么才能让 XPath 在这个 Atom 提要上工作?
Although this question has an answer, I found out this question has an almost exact duplicate: SelectNodes not working on stackoverflow feed
最佳答案
虽然 C# 实现可能允许默认命名空间(我不知道),但 XPath 1.0 规范不允许。所以,给“Atom”一个前缀:
nsMngr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
并适本地更改您的 XPath:
XmlNode node = atom.SelectSingleNode("//atom:entry/atom:link/app:edited", nsMngr);
关于c# - 没有使用 XPath 从 Atom XML 文档中选择节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/501171/
我有一台计算机在一个非常严格的代理服务器后面,它只允许我上网和下载程序它不允许像 Atom 文本编辑器这样的程序下载它的包。 我的问题是如何仅使用基于浏览器的下载来安装它们? 最佳答案 这当然是可能的
我的 keymap.cson 文件中有这个: 'body': 'ctrl-alt-left': 'editor:select-to-first-character-of-line' 但是不行(没有
如何获取 Atom 中所有已安装和已激活插件的列表? 我可以用 apm list --installed --bare获取所有已安装的软件包,但我不想包含禁用的软件包。而且我有很多禁用的包。 最佳答案
我在 OSX 上,在 Atom 中打开了一个我没有命名的文件。我不得不重新启动计算机,当它再次出现时,我点击了错误的东西,它忘记了所有旧文件名,并且未命名的文件似乎消失得无影无踪。如果我使用 Time
当我搜索某个字符串(“在目录中搜索”)时,atom 允许做两件事:指定目录或文件扩展名(但它会在项目中的所有目录中搜索)。是否可以同时进行?例如。我想在 'src' 目录中进行递归搜索,但只使用 *.
我将 OSX 更新为 High Sierra,我的 Atom 停止从命令行工作。 $ atom . FSPathMakeRef(/Applications/Atom.app) failed with
下面屏幕截图中第 95 行和第 96 行之间的红色箭头在 GitHub 的 Atom 编辑器上意味着什么? 谢谢! 最佳答案 如果您当前打开的项目使用 Git 作为修订系统,装订线中的箭头表示您删除了
某些代码编辑器(例如 WebStorm)可以选择在编辑器失去焦点时自动保存。我在 Atom 编辑器中搜索了类似的选项,但尚未找到任何内容。 Atom 编辑器是否有一个设置,允许在失去焦点时自动保存已编
有没有办法(插件或其他东西)在 Atom 编辑器中使用分屏? 我查看了菜单,但找不到任何相关选项。 最佳答案 使用命令面板 使用 cmd + shift + p (OSX) 或 ctrl + 打开命令
我在 Atom 中安装了一个有缺陷的软件包,它导致编辑器反复崩溃。因此,我进入 Atom 设置将其删除,但出于好奇,我事先单击了“打开配置文件夹”按钮,这打开了一个空窗口和开发工具: Atom 随后崩
我已经使用atom.io有一段时间了并且非常喜欢它。我只缺少一件事。我以前使用过bracket和sublime,它们都有一个功能,你只需输入html就可以创建html文档的基本结构。 这只会设置 ht
我尝试在 Atom 编辑器中安装软件包,但总是失败,就像我无法连接到服务器一样。 例如,apm install split-diff 返回请求包信息失败:getaddrinfo ENOTFOUNDat
我使用的是 OSX El Capitan 和 Atom 1.2.4。而且我还安装了“tabs-to-spaces”包。 我正在尝试将编辑器设置为缩进并使制表符为 2 个空格。但我无法完成这项工作,这是
我使用的是 Atom 1.0.15。启动时,Atom 每次都会尝试打开 MTP 设备上的文件,这非常烦人。即使关闭引用 MTP 设备上的文件的选项卡后,Atom 也会尝试在下次启动时重新打开它。 修复
我在 Atom 中安装了一个有缺陷的软件包,它导致编辑器反复崩溃。因此,我进入 Atom 设置将其删除,但出于好奇,我事先单击了“打开配置文件夹”按钮,这打开了一个空窗口和开发工具: Atom 随后崩
我尝试在 Atom 编辑器中安装软件包,但总是失败,就像我无法连接到服务器一样。 例如,apm install split-diff 返回请求包信息失败:getaddrinfo ENOTFOUNDat
在 Atom 文本编辑器上,不同的文件树颜色代表什么。我的文件有 3 种不同的颜色:黑色、绿色和橙色。黑色文件无法正常运行,而绿色文件运行良好。如果有人知道颜色的具体含义,请告诉我。 最佳答案 颜色指
我正在尝试通过 Atom 进行完整搜索,寻找特定的文本。嗯,这听起来很简单,使用 Command + Shift + F ,但是,不会跟踪 node_modules ,并且不会扫描这些目录内的内容。我
以下是我在snippets.cson 文件中编写的两个片段: '.source.python': 'print statement': 'prefix': 'pr' 'body'
我试过在这里查看其他有类似问题的问题,但不幸的是我没能解决这个问题。 关于一些基本背景信息,我目前在实验室中使用 PC,并且实验室在机构的某个地方有 GPU 服务器。我正在尝试将 Atom 编辑器连接
我是一名优秀的程序员,十分优秀!