Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R XML包解析XML和html文件时出现奇怪的错误_Html_Xml_R_Xml Parsing_Html Parsing - Fatal编程技术网

R XML包解析XML和html文件时出现奇怪的错误

R XML包解析XML和html文件时出现奇怪的错误,html,xml,r,xml-parsing,html-parsing,Html,Xml,R,Xml Parsing,Html Parsing,我正在使用R的XML包在各种html和XML文件上提取所有可能的数据。这些文件基本上是文档、构建属性或自述文件 <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE chapter PUBLIC '-//OASIS//DTD DocBook XML V4.1.2//EN' 'http://www.oasis-open.org/docbook/xml/4.0 docbookx.dtd'>

我正在使用R的XML包在各种html和XML文件上提取所有可能的数据。这些文件基本上是文档、构建属性或自述文件

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE chapter PUBLIC '-//OASIS//DTD DocBook XML V4.1.2//EN'
                      'http://www.oasis-open.org/docbook/xml/4.0 docbookx.dtd'>

<chapter lang="en">
<chapterinfo>
<author>
<firstname>Jirka</firstname>
<surname>Kosek</surname>
</author>
<copyright>
<year>2001</year>
<holder>Ji&rcaron;&iacute; Kosek</holder>
</copyright>
<releaseinfo>$Id: htmlhelp.xml,v 1.1 2002/05/15 17:22:31 isberg Exp $</releaseinfo>
</chapterinfo>
<title>Using XSL stylesheets to generate HTML Help</title>
<?dbhtml filename="htmlhelp.html"?>

<para>HTML Help (HH) is help-format used in newer versions of MS
Windows and applications written for this platform. This format allows
to pack several HTML files together with images, table of contents and
index into single file. Windows contains browser for this file-format
and full-text search is also supported on HH files. If you want know
more about HH and its capabilities look at <ulink
url="http://msdn.microsoft.com/library/tools/htmlhelp/chm/HH1Start.htm">HTML
Help pages</ulink>.</para>

<section>
<title>How to generate first HTML Help file from DocBook sources</title>

<para>Working with HH stylesheets is same as with other XSL DocBook
stylesheets. Simply run your favorite XSLT processor on your document
with stylesheet suited for HH:</para>

</section>

</chapter>
但是,当我对xml和html文件都这样做时,有一个错误。如果在级别2或更高的级别上存在子节点,则将粘贴文本字段,但它们之间没有任何空格

例如,在上面的示例中

xmlValue(chapterInfo)是

每个子节点(递归)的xmlValues粘贴在一起,而不在它们之间添加空间。如何让xmlValue在提取此数据时添加空白

非常感谢您事先的帮助


Shivani

根据文档,
xmlValue
只起作用 在单个文本节点上,或在“包含单个文本节点的XML节点”上。 非文本节点中的空格显然不保留

但是,即使在单个文本节点的情况下, 您的代码将删除空白

库(XML)

博士,如果回答者的回答解决了您的问题,请务必接受回答者的回答。您可以通过选择响应旁边的勾号来完成此操作。
Text = xmlValue(xmlRoot(xmlTreeParse(XMLFileName)))
JirkaKosek2001JiKosek$Id: htmlhelp.xml,v 1.1 2002/05/15 17:22:31 isberg Exp