标签: libxml2

我使用 Xpath 时命名空间和 libxml 的问题

当我在 XPath 中使用 libxml 时遇到问题。我想解析一个 youtube 播放列表:

<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
  xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
  xmlns:media='http://search.yahoo.com/mrss/'
  xmlns:batch='http://schemas.google.com/gdata/batch'
  xmlns:yt='http://gdata.youtube.com/schemas/2007'
  xmlns:gd='http://schemas.google.com/g/2005'
  gd:etag='W/&quot;Dk8DRn47eCp7ImA9WxRQGEk.&quot;'>
  <id>tag:youtube,2008:user:andyland74:playlists</id>
  <updated>2008-07-21T16:43:25.232Z</updated>
  <category scheme='http://schemas.google.com/g/2005#kind'
    term='http://gdata.youtube.com/schemas/2007#playlistLink'/>
  <title>Playlists of andyland74</title>
  <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo>
  <link rel='related' type='application/atom+xml'
    href='http://gdata.youtube.com/feeds/api/users/andyland74?v=2'/>
  <link rel='alternate' type='text/html'
    href='http://www.youtube.com/profile_play_list?user=andyland74'/>
  <link rel='http://schemas.google.com/g/2005#feed'
    type='application/atom+xml'
    href='http://gdata.youtube.com/feeds/api/users/andyland74/playlists?v=2'/>
  <link rel='http://schemas.google.com/g/2005#post'
    type='application/atom+xml'
    href='http://gdata.youtube.com/feeds/api/users/andyland74/playlists?v=2'/>
  <link rel='http://schemas.google.com/g/2005#batch'
    type='application/atom+xml'
    href='http://gdata.youtube.com/feeds/api/users/andyland74/playlists/batch?v=2'/>
  <link rel='self' type='application/atom+xml'
    href='http://gdata.youtube.com/feeds/api/users/andyland74/playlists?...'/>
  <link rel='service' type='application/atomsvc+xml'
    href='http://gdata.youtube.com/feeds/api/users/andyland74/playlists?alt=...'/>
  <author>
    <name>andyland74</name>
    <uri>http://gdata.youtube.com/feeds/api/users/andyland74</uri>
  </author>
  <generator version='2.0'
    uri='http://gdata.youtube.com/'>YouTube data API</generator>
  <openSearch:totalResults>3</openSearch:totalResults>
  <openSearch:startIndex>1</openSearch:startIndex>
  <openSearch:itemsPerPage>25</openSearch:itemsPerPage>
  <entry gd:etag='W/&quot;Dk8DRn47eCp7ImA9WxRQGEk.&quot;'>
    <id>tag:youtube,2008:user:andyland74:playlist:8BCDD04DE8F771B2</id>
    <published>2007-11-04T17:30:27.000-08:00</published>
    <updated>2008-07-15T12:33:20.000-07:00</updated>
    <app:edited xmlns:app='http://www.w3.org/2007/app'>2008-07-15T12:33:20.000-07:00</app:edited>
    <category scheme='http://schemas.google.com/g/2005#kind'
      term='http://gdata.youtube.com/schemas/2007#playlistLink'/>
    <title>My New Playlist …
Run Code Online (Sandbox Code Playgroud)

xpath libxml2

5
推荐指数
1
解决办法
5157
查看次数

使用libxml获取节点的所有属性的列表

我很难找到一种方法来提取节点的所有属性的列表,而不知道它们被称为什么.

我使用以下方法提取单个已知属性:

xmlGetProp(cur, (const xmlChar*)"nodename")

但是如何使用libxml2获取所有属性的列表?

问候,marius

c xml libxml2

5
推荐指数
1
解决办法
6821
查看次数

使用libxml2创建字符串(c ++)

我的问题是我想创建xml树并获得一个简单的字符串对象(甚至是char*).我无法将xml保存到文件中.

所以在输入中我有xmlDocPtr和完整的xml树,并希望得到包含xml但不使用文件的字符串.

请注意.

c++ libxml2

5
推荐指数
1
解决办法
7538
查看次数

如何在没有'extconf failure:需要libxml2'的情况下安装ruby gem libxml

我目前正在尝试安装一个失败的ruby gem,因为extconf说它需要libxml,所以当我按照这些说明安装libxml(包括ruby开发工具包安装的这些说明)时,我得到以下输出:

$ gem install libxml-ruby --platform x86-mswin32-60
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
    ERROR: Failed to build gem native extension.

    c:/Ruby/bin/ruby.exe extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... yes
checking for inflate() in -lz... no
checking for inflate() in -lzlib... no
checking for inflate() in -lzlib1... yes
checking for iconv_open() in -liconv... …
Run Code Online (Sandbox Code Playgroud)

ruby windows gem rubygems libxml2

5
推荐指数
1
解决办法
6706
查看次数

无法在Centos 6.2上使用RVM 1.9.3安装nokogiri

/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': 
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
Run Code Online (Sandbox Code Playgroud)

我在CentOS 6.2服务器上使用RVM安装了ruby 1.9.3.当我尝试运行gem install nokogiri它时产生下面的输出.我已经访问了nokogiri网站并使用yum安装了libxml2和libxslt依赖项:

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
Run Code Online (Sandbox Code Playgroud)

我还安装了libxml2和libxslt软件包,rvm pkg install然后重新安装了ruby.

我一直在寻找解决方案,但我还没有找到任何东西.任何想法,将不胜感激 :)

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack …
Run Code Online (Sandbox Code Playgroud)

ruby centos libxml2 nokogiri rvm

5
推荐指数
1
解决办法
7970
查看次数

lxml._ElementTree.getpath(element) 为非默认命名空间中的元素返回“*”而不是标签名称

请帮助getpath()getpath()xpath 中返回完整的标签名称或找到解决方法

我正在尝试为lxml.etree._ElementTree. ElementTree通过解析来自某些生产 WebService 的 600Kb 响应生成。

print elem.getroottree().getpath(elem)
Run Code Online (Sandbox Code Playgroud)

这是我得到的结果:

'/S:Envelope/S:Body/ns5:getPhysicalResponse/*[18]/*[12]/*[6]/*[2]'
Run Code Online (Sandbox Code Playgroud)

不幸的是,我无法发布原始 xml - 它包含专有的客户信息。此外,我尝试使用自动生成的具有 100 个嵌套级别的简单元素树来重现此结果,每个级别有 100 个子级,但没有运气 -getpath()返回带有完整标签名称的 xpath。

更新 查看lxml 源代码- 它指向库中的tree.h xmlGetNodePath方法libxml2。所以这实际上是libxml2行为。

更新 做更多的测试,我发现每次标签具有非默认命名空间时都会发生这种情况。

c++ python xpath lxml libxml2

5
推荐指数
1
解决办法
738
查看次数

如何获取 xmlBuf 以与 xmlBufGetNodeContent/xmlBufNodeDump 等一起使用?

描述xmlNodeDump()(其需要一个xmlBufferPtr)状态:

由于这是使用 xmlBuffer 结构,它被限制为 2GB 并且以某种方式被弃用,请改用 xmlBufNodeDump()。

很公平,但是因为xmlBufNodeDump()(和 eg xmlBufGetNodeContentxmlBufPtr提出了我的问题:如何创建这样的xmlBuf缓冲区?

我找不到任何明显的东西。

以及如何释放它?

我的意思是,因为xmlBuffer有例如xmlBufferCreate()

或者应该获得一个xmlOutputBuffer通孔xmlAllocOutputBuffer()并将其xmlOutputBuffer::buffer 属性(类型xmlBuf*)用于xmlBufNodeDump()

libxml2

5
推荐指数
1
解决办法
810
查看次数

如何使用 libxml C 库获取 XML 中的属性?

某项任务要求我解析 XML 文件并检查每个节点及其属性。我花了几周时间学习 XML 和 XML 解析。我什至接受了之前发布的与 C 中的 LIBXML 解析相关的问题的帮助,并基于这种理解我编写了下面的代码。但这段代码是有缺陷的,因为我没有实现目标。

我想我搞乱了一些父母、孩子和兄弟姐妹的概念。我从下面提到的 XML 文件中了解到的是:

Profile 是根节点,Catalog 是其子节点,Catalog 的子节点作为参数,Parameter 的子节点作为目标节点,并且所有目录节点彼此互为兄弟节点。

Profile--> Catalog--> Parameter-->Target
       |-> Catalog--> Parameter-->Target
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试通过将指针移动到目录子节点指针来从目录转到参数时,我无法进行。由于我无法达到参数,我无法达到目标。

希望纠正我的理解和代码。PS 我的要求是用 C 语言编写代码,所以请不要向我指出其他语言。

/***** MY XML FILE ***************************/

<?xml version="1.0" encoding="UTF-8"?>
<!-- When VIOS level changes, the value of ioslevel needs to change  manually -->
<Profile origin="get" version="3.0.0" date="2012-10-05T00:00:00Z">
 <Catalog1 id="devParam" version="3.0">
  <Parameter1 name="policy" value="single" applyType="boot" reboot="true">
   <Target1 class="device" instance="disk1"/>
  </Parameter1>
 </Catalog1>
 <Catalog2 id="devParam" version="3.0">
  <Parameter2 name="policy" value="no" applyType="boot">
   <Target2 class="device" instance="disk2"/>
  </Parameter2> …
Run Code Online (Sandbox Code Playgroud)

c xml libxml2 xml-parsing

5
推荐指数
1
解决办法
2733
查看次数

在 Fedora 27 中的 R 中安装 xml2

我在运行 Fedora 27 的 RStudio 中安装 xml2 时遇到问题。运行时install.packages('xml2'),出现以下错误:

\n\n
installing to /home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2/libs\n** R\n** inst\n** preparing package for lazy loading\n** help\nError : /tmp/Rtmp2sKZQZ/R.INSTALL689b37bd918d/xml2/man/read_xml.Rd:47: unable to load shared object '/home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2/libs/xml2.so':\n  libicui18n.so.58: cannot open shared object file: No such file or directory\nERROR: installing Rd objects failed for package \xe2\x80\x98xml2\xe2\x80\x99\n* removing \xe2\x80\x98/home/ryi/R/x86_64-redhat-linux-gnu-library/3.4/xml2\xe2\x80\x99\nWarning in install.packages :\n  installation of package \xe2\x80\x98xml2\xe2\x80\x99 had non-zero exit status\n\nThe downloaded source packages are in\n    \xe2\x80\x98/tmp/RtmpPs5Gzi/downloaded_packages\xe2\x80\x99\n
Run Code Online (Sandbox Code Playgroud)\n\n

我注意到在我的 中/usr/lib64/,我只有libicui18n.so.57,所以我尝试在那里复制 a libicui18n.so.58,但出现以下错误:

\n\n
installing to …
Run Code Online (Sandbox Code Playgroud)

r fedora libxml2 xml2

5
推荐指数
1
解决办法
2078
查看次数

XSLT 1.0 (xsltproc) - 无法解析巨大的 XML

我正在尝试使用 xsltproc 解析一个 13,00,000 行长、大小为 56 MB 的输入 xml 文件。我收到以下错误:

input.xml:245393: parser error : internal error: Huge input lookup
              "description" : "List of values for possible department codes"
                          ^
unable to parse input.xml
Run Code Online (Sandbox Code Playgroud)

我的 xsltproc 能够处理一个 9,30,000 行长、大小为 48 MB 的 xml 文件。

事实上,我尝试通过删除不必要的部分将 xml 行减少到 600,000 行。尽管如此,还是出现同样的错误,这很奇怪,因为它能够解析 900,000,但不能解析 600,000。

我该如何解决这个问题?

xml xslt libxml2 xslt-1.0 xml-parsing

5
推荐指数
1
解决办法
1194
查看次数

标签 统计

libxml2 ×10

xml ×3

c ×2

c++ ×2

ruby ×2

xml-parsing ×2

xpath ×2

centos ×1

fedora ×1

gem ×1

lxml ×1

nokogiri ×1

python ×1

r ×1

rubygems ×1

rvm ×1

windows ×1

xml2 ×1

xslt ×1

xslt-1.0 ×1