带有未闭合标签而不是属性的XML

时间:2016-08-02 11:37:21

标签: php xml xml-parsing

我有一个我想通过php阅读的xml。文件的形式如下:

myCorpus <- tm_map(myCorpus, stemCompletion,
                   dictionary = myCorpusCopy, lazy = TRUE)
> tdm <- TermDocumentMatrix(myCorpus, control = list(wordLengths = c(1, Inf)))
Error in UseMethod("meta", x) : 
  no applicable method for 'meta' applied to an object of class "try-error"
In addition: Warning messages:
1: In mclapply(x$content[i], function(d) tm_reduce(d, x$lazy$maps)) :
  all scheduled cores encountered errors in user code
2: In mclapply(unname(content(x)), termFreq, control) :
  all scheduled cores encountered errors in user code

问题是它不使用属性。例如,它使用:<?xml version='1.0'?> <at> <f>ase <xx>20160801</xx> <S>AENE <G>100000,635</G> </S> <I>AAT <G>171434,245460</G> <A>103034,12080</A> <A>103534,15191</A> </I> <B>CCF <G>200000,10000</G> </B> <S>GGT <G>300000,10.4</G> </S> <S>HHT <G>300000,26.4</G> </S> </f> </at> 而不是<S>AENE。 在那种情况下,我没有找到一种方法来获取这些数据:

<S name="AENE">

simplexml_load_string工作正常,但我怎么能拿这个数据呢? $xml->at->f->S[0] (并将其放在变量中)。我想要的是能够从xml文件中获取信息。

提前致谢。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。

$xml->f->S[0]

按照我的想法,没有必要在每一行关闭标签。我犯的错误是我在路径中使用了<at>标签。

相关问题