js RDF Parser
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
只回答业务咨询
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#"; var xmlString = '<?xml version="1.0" encoding="utf-8"?><RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"><Description about="urn:mozilla:install-manifest"><em:id>PortableTester@jetpack</em:id><em:version>initial</em:version><em:type>2</em:type><em:bootstrap>true</em:bootstrap><em:unpack>false</em:unpack><!--Firefox--><em:targetApplication><Description><em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id><em:minVersion>7.0</em:minVersion><em:maxVersion>27.0</em:maxVersion></Description></em:targetApplication><!--Front End MetaData--><em:name>PortableTester</em:name><em:description>Test addon that tries to figure out if Firefox is portable or not.</em:description><em:creator>Noitidart</em:creator><em:optionsURL>options url here</em:optionsURL></Description></RDF>'; var rdfParser = Cc['@mozilla.org/rdf/xml-parser;1'].createInstance(Ci.nsIRDFXMLParser); var ds = Cc['@mozilla.org/rdf/datasource;1?name=in-memory-datasource'].createInstance(Ci.nsIRDFDataSource); var emptyUri = Services.io.newURI('urn:none', null, null); rdfParser.parseString(ds, emptyUri, xmlString); var resources = ds.GetAllResources() while (resources.hasMoreElements()) { let resource = resources.getNext().QueryInterface(Ci.nsIRDFResource); let arcs = ds.ArcLabelsOut(resource); while (arcs.hasMoreElements()) { let arc = arcs.getNext().QueryInterface(Ci.nsIRDFResource); let prop = arc.ValueUTF8.substring(PREFIX_NS_EM.length) let targets = ds.GetTargets(resource, arc, true); while (targets.hasMoreElements()) { let target = targets.getNext(); if (target instanceof Ci.nsIRDFResource) { console.log(prop, "Resource node, recurse"); } else if (target instanceof Ci.nsIRDFLiteral) { console.log(prop, target.Value); //are non ASCII characters encoded? } else if (target instanceof Ci.nsIRDFInt) { console.log(prop, target.Value); } } } } |
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=1056