Tag: libxml2

节点-v 0.6.19。 libxmljs。 TypeError:无法读取未定义的属性“原型”

在Ubuntu 11.10上,安装了libxml2(2.7.8)和libxml2-dev的节点为0.6.17,0.6.18和0.6.19,一切正常。 在节点为0.6.19的FreeBSD服务器上,使用libxml2版本20708(xmllint –version; xmllint:使用libxml版本20708),它会提供以下错误消息: /home/pathtofile/www/node_modules/libxmljs/lib/element.js:24 Element.prototype = bindings.Element.prototype; ^ TypeError: Cannot read property 'prototype' of undefined at Object. (/home/pathtofile/www/node_modules/libxmljs/lib/element.js:24:37) at Module._compile (module.js:446:26) at Object..js (module.js:464:10) at Module.load (module.js:353:31) at Function._load (module.js:311:12) at Module.require (module.js:359:17) at require (module.js:375:17) at Object. (/home/pathtofile/www/node_modules/libxmljs/lib/document.js:3:15) at Module._compile (module.js:446:26) at Object..js (module.js:464:10)

如何使用libxmljs处理子节点(Node.js)

当我尝试使用libxmljsparsing以下xml时,我感到困惑: <?xml version =“1.0”encoding =“UTF-8”?> <结果集> <结果> <标题>标题1 </标题> <Summary> Summary 1 </ Summary> </结果> <结果> <标题>标题2 </标题> <Summary> Summary 2 </ Summary> </结果> </结果集> 我试过下面的代码: var libxmljs = require("libxmljs"); var xmlDoc = libxmljs.parseXmlFile("sample.xml"); xmlDoc.root().childNodes().length; // 5 我认为第三行的length属性应该是2,因为有2个Result节点,它们是根节点的子节点。 顺便说一下,我检查了每个元素,如: xmlDoc.root().childNodes()[0].get("Title").text(); // TypeError: Cannot call method 'text' of undefined xmlDoc.root().childNodes()[1].get("Title").text(); // Title 1 xmlDoc.root().childNodes()[2].get("Title").text(); // TypeError: […]

parsingXML Libxmljs(Node.js)

我试图用libxmljsparsing一个XMLstring(https://github.com/polotek/libxmljs) 。 我有一些问题,但。 我需要将逻辑应用于我正在parsing的内容,并根据定义的内容和不是什么内容进行返回。 正因为如此,我没有看到一个SAX风格的parsing器是一个有效的select。 我愿意看看其他的select,如果我能达到我所期待的。 能够select像DOMParser xmlDoc.getElementsById('firstName')[0].childNodes[0].nodeValue将是可怕的…