- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我使用以下代码解析了一个 XML 文件并得到如下结果:
url = htmlTreeParse("http://www.appannie.com/app/ios/candy-crush-saga/", useInternalNodes = T)
ItemList =getNodeSet(url, "//li/a/@title")
>ItemList
[[1]]
title
"Angry Birds Star Wars HD"
attr(,"class")
[1] "XMLAttributeValue"
[[2]]
title
"iShuffle Bowling 2"
attr(,"class")
[1] "XMLAttributeValue"
....
[[15]]
title
"Angry Birds Star Wars Free"
attr(,"class")
[1] "XMLAttributeValue"
attr(,"class")
[1] "XMLNodeSet"
我的问题是我想通过解析来获取游戏的名称。所以我尝试了这段代码(根据我处理 xmlValue 的经验)-
IL <- lapply(ItemList, function(x) c(xmlValue(x), xmlAttrs(x)[["href"]]))
但它最终给出了这个错误:
Error in UseMethod("xmlValue") : no applicable method for 'xmlValue' applied to an object of class "XMLAttributeValue"
我进行了大量谷歌搜索,但找不到处理 XMLAttributeValue 的解决方案。有人可以给我提示,让我知道 xmlValue 和 xmlAttributeValue 之间的区别吗?
最佳答案
感谢更新的问题和添加的示例 URL!
我认为对于 @title
,您已经了解了属性,这就是您无法解析 xmlValue
的原因。例如:
> htmlTreeParse("http://www.appannie.com/app/ios/candy-crush-saga/", useInternalNodes = TRUE)
> xpathSApply(url, "//li/a", function(x) c(xmlValue(x), xmlAttrs(x)[["href"]]))
更新:要过滤结果,您可以只尝试xpathSApply
“Customers Also Bought”div:
> xpathSApply(url, "//div[@class='app_content_section']/ul/li/a", function(x) c(xmlValue(x), xmlAttrs(x)[["href"]]))
关于xmlvalue 与 XMLAttributeValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15281411/
我使用以下代码解析了一个 XML 文件并得到如下结果: url = htmlTreeParse("http://www.appannie.com/app/ios/candy-crush-saga/",
我想要这样的 XML: Foo 我可以通过一个看起来像这样的 JAXB 类成功地做到这一点: @XmlRootElement(name="simple") class Simple { @Xm
我有以下代码 @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "udt_TextType", propOrder = { "value" }
目标是使用 JAXB 生成以下 XML string data binary data 是否有允许generic 的解决方法@XmlValue字段(我需要存储 byte[] 和 Str
跟进JAXB and Composite Pattern ,我设法映射: foo bar
@JsonValue javadoc 声明:“类似于 javax.xml.bind.annotation.XmlValue 的标记注释”。为什么相似,有什么不同? 我作为 JAXB 的新手问这个问题,
是否可以有一个用值 AND 元素呈现的 JAXB 元素? 我正在尝试渲染类似的内容: This is some text 它甚至知道可能不是有效的 XML,但不幸的是,我尝试呈现
我是 JAXB 的新手,在从 XML 到 Java 类实例的转换方面遇到了麻烦。 我有以下 XML: client Greeting 1000 Your Conne
假设我有以下内容: library(XML) my.xml Star Trek TNG 1.0 Doctor Who Babylo
我看到这里发布了一个类似的问题,但它并没有帮助我解决问题,所以我在这里发布我的问题,看看是否有人可以修改我的代码以使其工作。 问题:如何访问混合内容字符串值并将其保存在 setPhrase(Strin
我想表示 List> 的一个实例在 XML 中如下所示: value1 value2 2012-08-19T13:00:59.412-04:00 哪里key1和 key2
现在我们正在构建一个函数,使用 apache.poi 将大型 xlsx 文件(超过 200MB)导入到数据库,并遍历读取该数据的所有 xml 文件。 该功能已完成,但有一个问题: 当我在 xlsx 单
bean : @XmlRootElement(name = "integer") @XmlAccessorType(XmlAccessType.FIELD) public class IntegerW
我已经看过一些与此相关的讨论,但无法在以下场景中应用。我正在尝试使用 jaxb 解码 xml。以下是我所有类(class)的层次结构。 @XmlRootElement(name="entry")
我有一个问题,其中 xmlValue剥离 我需要保留的标签(或转换为我可以 strsplit 打开的其他字符。 这是一个例子: > f xpathSApply(f, "//div[@class=\"
是否可以在使用@XmlElementRef 注释的引用对象上使用@XmlValue 注释?目标是生成以下 XML 输出: Blah 给定以下示例 JAXBContex
您好,我正在解码一个 XML 文件,该文件的标签可以包含一个值或一个元素列表。我想知道解码这种 XML 的最佳方法是什么。示例: value1 value2 value3
我收到以下错误: If a class has @XmlElement property, it cannot have @XmlValue property 更新类: @XmlType(pr
我有下一个 html,我想解析它: My input: bla bla bla bla My output in java: jaxbContext = JAX
我正在尝试使用 JAXB 定义 XML 到 Java 对象的绑定(bind)。一切正常,除非我尝试生成 XML,如this: Get Price read-only 来自 类定义为
我是一名优秀的程序员,十分优秀!