使用jquery从XML Request修改数据

时间:2018-04-06 12:00:49

标签: javascript jquery xmlhttprequest

我尝试从网站的RSS获取数据。但我有一些错误

抱歉,我的英语不好

我的代码:

$.ajax({
type: "GET",
url: "https://tuhoc247.com/feed/",
dataType: "xml",
success: function (xml) {
  $(xml).find('item').each(function () {
    console.log("title      : " + $(this).find("title").text());
    console.log("link       : " + $(this).find("link").text());
    var $html = $(this).find('content\\:encoded').html()
    console.log($html.find('ul').text());
  });
},
error: function () {
  alert("An error occurred.");
}
});

但是错误:" $ html.find不是函数"

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

更改:

# load packages
require("ggplot2")
require("reshape2")

###############################################################################

# Create list of tasks name strings.
tasks <- c("Write introduction", "Parse citation data",
           "Construct data timeline",
           "Write methods", "Model formulation", 
           "Model selection", "Write results", "Write discussion",
           "Write abstract and editing")

# Compile dataframe of task names, and respective start and end dates.
dfr <- data.frame(
  name = factor(tasks, levels = tasks),
  start.date = as.Date(c("2018-04-09", "2018-04-09", "2018-04-16",
                         "2018-04-30", "2018-04-16", "2018-05-21",
                         "2018-06-04", "2018-07-02", "2018-07-30")),
  end.date = as.Date(c("2018-04-30", "2018-04-20", "2018-05-18",
                       "2018-06-01", "2018-05-18", "2018-06-01",
                       "2018-06-29", "2018-07-27", "2018-08-31"))
)

# Merge start and end dates into durations.
mdfr <- melt(dfr, measure.vars = c("start.date", "end.date"))

###############################################################################

# Create gantt chart.

ggplot(mdfr, aes(value, name)) +
  geom_line(size=4) +
  xlab(NULL) +
  ylab(NULL) +
  ggtitle("Project gantt chart") +
  theme_minimal() +
  theme(aspect.ratio = 0.3, axis.text = element_text(size = 10)) 

致:

console.log($html.find('ul').text());