这篇教程C++ xpath函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xpath函数的典型用法代码示例。如果您正苦于以下问题:C++ xpath函数的具体用法?C++ xpath怎么用?C++ xpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xpath函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: readerbool Container::Open(const string& path){ _archive = Archive::Open(path.stl_str()); if (_archive == nullptr) throw std::invalid_argument(_Str("Path does not point to a recognised archive file: '", path, "'")); _path = path; // TODO: Initialize lazily? Doing so would make initialization faster, but require // PackageLocations() to become non-const, like Packages(). ArchiveXmlReader reader(_archive->ReaderAtPath(gContainerFilePath)); if (!reader) { throw std::invalid_argument(_Str("Path does not point to a recognised archive file: '", path, "'")); }#if EPUB_USE(LIBXML2) _ocf = reader.xmlReadDocument(gContainerFilePath, nullptr, XML_PARSE_RECOVER|XML_PARSE_NOENT|XML_PARSE_DTDATTR);#else decltype(_ocf) __tmp(reader.ReadDocument(gContainerFilePath, nullptr, /*RESOLVE_EXTERNALS*/ 1)); _ocf = __tmp;#endif if (!((bool)_ocf)) return false;#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS) XPathWrangler xpath(_ocf, { { "ocf", "urn:oasis:names:tc:opendocument:xmlns:container" } });#else XPathWrangler::NamespaceList __ns; __ns["ocf"] = OCFNamespaceURI; XPathWrangler xpath(_ocf, __ns);#endif xml::NodeSet nodes = xpath.Nodes(gRootfilesXPath); if (nodes.empty()) return false; LoadEncryption(); for (auto n : nodes) { string type = _getProp(n, "media-type"); string path = _getProp(n, "full-path"); if (path.empty()) continue; auto pkg = Package::New(Ptr(), type); if (pkg->Open(path)) _packages.push_back(pkg); } auto fm = FilterManager::Instance(); for (auto& pkg : _packages) { auto fc = fm->BuildFilterChainForPackage(pkg); pkg->SetFilterChain(fc); } return true;}
开发者ID:datalogics-bhaugen,项目名称:SDKLauncher-Windows,代码行数:58,
示例2: EPUB_COMPILER_SUPPORTSstring Package::PackageID() const{#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS) XPathWrangler xpath(_opf, {{"opf", OPFNamespace}, {"dc", DCNamespace}});#else XPathWrangler::NamespaceList __m; __m["opf"] = OPFNamespace; __m["dc"] = DCNamespace; XPathWrangler xpath(_opf, __m);#endif XPathWrangler::StringList strings = xpath.Strings("//*[@id=/opf:package/@unique-identifier]/text()"); if ( strings.empty() ) return string::EmptyString; return strings[0];}
开发者ID:becka11y,项目名称:readium-sdk,代码行数:15,
示例3: xpathvoid CLogContentFilter::readAllLogFilters(IPropertyTree* cfg){ bool groupFilterRead = false; VStringBuffer xpath("Filters/Filter[@type='%s']", espLogContentGroupNames[ESPLCGBackEndResp]); IPropertyTree* filter = cfg->queryBranch(xpath.str()); if (filter && filter->hasProp("@value")) { logBackEndResp = filter->getPropBool("@value"); groupFilterRead = true; } xpath.setf("Filters/Filter[@type='%s']", espLogContentGroupNames[ESPLCGBackEndReq]); filter = cfg->queryBranch(xpath.str()); if (filter && filter->hasProp("@value")) { logBackEndReq = filter->getPropBool("@value"); groupFilterRead = true; } for (unsigned i = 0; i < ESPLCGBackEndReq; i++) { if (readLogFilters(cfg, i)) groupFilterRead = true; } if (!groupFilterRead) { groupFilters.clear(); readLogFilters(cfg, ESPLCGAll); }}
开发者ID:Michael-Gardner,项目名称:HPCC-Platform,代码行数:31,
示例4: createElementbool CPbl2XML::Convert(MSXML2::IXMLDOMElementPtr &library, _bstr_t &path){ MSXML2::IXMLDOMElementPtr childnode = library->ownerDocument-> createElement("childs"); char buffer[256] = {0}; int iResult = m_orca.LibraryDirectory((char *) path, buffer, sizeof(buffer), LibDir, (LPVOID) childnode.GetInterfacePtr()); if(iResult != PBORCA_OK) { CString msg; msg.Format("FAILED: LibraryDirectory(...) : %s", (char *) path); log.write(msg); childnode = NULL; return false; } _bstr_t xpath("childs"); MSXML2::IXMLDOMNodeListPtr childlist = library->selectNodes(xpath); if(childlist->length > 0) { library->replaceChild(childnode, childlist->item[0]); } else { library->appendChild(childnode); } // сохраняем значение комментария библиотеки library->setAttribute(_bstr_t("comment"), _bstr_t(buffer)); return true;}
开发者ID:vactorwu,项目名称:pbrebus,代码行数:32,
示例5: oDoc/* long GetNodeUrlCount (in nsIDOMNode node); */NS_IMETHODIMP nsDomAttUtil::GetNodeUrlCount(nsIDOMNode *node, PRInt32 *_retval ){ nsresult rv; nsCOMPtr<nsIXpathUtil> xpathUtil=do_CreateInstance("@nyapc.com/XPCOM/nsXpathUtil;1",&rv); if (NS_FAILED(rv)) { return rv; } nsCOMPtr<nsIDOMDocument> oDoc(nsnull); node->GetOwnerDocument(getter_AddRefs(oDoc)); if(oDoc!=nsnull) { xpathUtil->SetDocument(oDoc); nsCOMPtr<nsISupportsArray> nodeArr(nsnull); nsCString xpath(".//a[@href]"); xpathUtil->GetSubNodes(node,xpath,getter_AddRefs(nodeArr)); if(nodeArr!=nsnull) { PRUint32 arrlen=0; nodeArr->Count(&arrlen); *_retval=arrlen; }else { *_retval=0; } }else { *_retval=0; } return NS_OK;}
开发者ID:firememory,项目名称:dfwbi,代码行数:32,
示例6: wuidWsWuInfo::WsWuInfo(const char *wuid_, const char *qset, const char *qname, const char *user, const char *pw) : wuid(wuid_), qsetname(qset), queryname(qname), username(user), password(pw){ Owned<IWorkUnitFactory> wf = getWorkUnitFactory(); if (!wuid.length() && qsetname.length() && queryname.length()) { Owned<IPropertyTree> qstree = getQueryRegistry(qsetname.sget(), true); if (qstree) { VStringBuffer xpath("Query[@id=/"%s/"]", queryname.sget()); IPropertyTree *query = qstree->queryPropTree(xpath.str()); if (query) wuid.set(query->queryProp("@wuid")); else throw MakeStringException(-1, "Query %s not found in QuerySet %s", queryname.sget(), qsetname.sget()); } else throw MakeStringException(-1, "QuerySet %s not found", qsetname.sget()); } if (wuid.length()) { wu.setown(wf->openWorkUnit(wuid.sget(), false)); if (!wu) throw MakeStringException(-1, "Could not open workunit: %s", wuid.sget()); } else throw MakeStringException(-1, "Workunit not specified");}
开发者ID:hszander,项目名称:HPCC-Platform,代码行数:29,
示例7: getPkgInfovoid getPkgInfo(const IPropertyTree *packageMaps, const char *target, const char *process, StringBuffer &info){ Owned<IPropertyTree> tree = createPTree("PackageMaps"); Owned<IPropertyTree> pkgSetRegistry = getPkgSetRegistry(process, true); if (!pkgSetRegistry) { toXML(tree, info); return; } StringBuffer xpath("PackageMap[@active='1']"); if (target && *target) xpath.appendf("[@querySet='%s']", target); Owned<IPropertyTreeIterator> iter = pkgSetRegistry->getElements(xpath.str()); ForEach(*iter) { IPropertyTree &item = iter->query(); const char *id = item.queryProp("@id"); if (id) { StringBuffer xpath; xpath.append("PackageMap[@id='").append(id).append("']"); IPropertyTree *mapTree = packageMaps->queryPropTree(xpath); if (mapTree) mergePTree(tree, mapTree); } } toXML(tree, info);}
开发者ID:ruidafu,项目名称:HPCC-Platform,代码行数:29,
示例8: querySDSIPropertyTree *getPkgSetRegistry(const char *process, bool readonly){ Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT); if (!globalLock) throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to connect to PackageSet information in dali /PackageSets"); IPropertyTree *pkgSets = globalLock->queryRoot(); if (!pkgSets) throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to open PackageSet information in dali /PackageSets"); if (!process || !*process) process = "*"; StringBuffer id; buildPkgSetId(id, process); //Only lock the branch for the target we're interested in. VStringBuffer xpath("/PackageSets/PackageSet[@id='%s']", id.str()); Owned<IRemoteConnection> conn = querySDS().connect(xpath.str(), myProcessSession(), readonly ? RTM_LOCK_READ : RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT); if (!conn) { if (readonly) return NULL; Owned<IPropertyTree> pkgSet = createPTree(); pkgSet->setProp("@id", id.str()); pkgSet->setProp("@process", process); pkgSets->addPropTree("PackageSet", pkgSet.getClear()); globalLock->commit(); conn.setown(querySDS().connect(xpath.str(), myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT)); } return (conn) ? conn->getRoot() : NULL;}
开发者ID:ruidafu,项目名称:HPCC-Platform,代码行数:33,
示例9: doCreate void doCreate(const char *partname, const char *xml, unsigned updateFlags, StringArray &filesNotFound) { createPart(partname, xml); if (pmExisting) { if (!checkFlag(PKGADD_MAP_REPLACE)) throw MakeStringException(PKG_NAME_EXISTS, "PackageMap %s already exists, either delete it or specify overwrite", pmid.str()); } cloneDfsInfo(updateFlags, filesNotFound); if (pmExisting) packageMaps->removeTree(pmExisting); Owned<IPropertyTree> pmTree = createPTree("PackageMap", ipt_ordered); pmTree->setProp("@id", pmid); pmTree->setPropBool("@multipart", true); pmTree->addPropTree("Part", pmPart.getClear()); packageMaps->addPropTree("PackageMap", pmTree.getClear()); VStringBuffer xpath("PackageMap[@id='%s'][@querySet='%s']", pmid.str(), target.get()); Owned<IPropertyTree> pkgSet = getPkgSetRegistry(process, false); IPropertyTree *psEntry = pkgSet->queryPropTree(xpath); if (!psEntry) { psEntry = pkgSet->addPropTree("PackageMap", createPTree("PackageMap")); psEntry->setProp("@id", pmid); psEntry->setProp("@querySet", target); } makePackageActive(pkgSet, psEntry, target, checkFlag(PKGADD_MAP_ACTIVATE)); }
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:33,
示例10: EPUB_COMPILER_SUPPORTSstring Container::Version() const{#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS) XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}});#else XPathWrangler::NamespaceList __ns; __ns["ocf"] = OCFNamespaceURI; XPathWrangler xpath(_ocf, __ns);#endif std::vector<string> strings = xpath.Strings(gVersionXPath); if ( strings.empty() ) return "1.0"; // guess return std::move(strings[0]);}
开发者ID:becka11y,项目名称:readium-sdk,代码行数:16,
示例11: _archiveContainer::Container(const std::string& path) : _archive(Archive::Open(path)){ if ( _archive == nullptr ) throw std::invalid_argument("Path does not point to a recognised archive file: '" + path + "'"); // TODO: Initialize lazily? Doing so would make initialization faster, but require // PackageLocations() to become non-const, like Packages(). ArchiveXmlReader reader(_archive->ReaderAtPath(gContainerFilePath)); _ocf = reader.xmlReadDocument(gContainerFilePath, nullptr, XML_PARSE_RECOVER|XML_PARSE_NOENT|XML_PARSE_DTDATTR); if ( _ocf == nullptr ) throw std::invalid_argument(std::string(__PRETTY_FUNCTION__) + ": No container.xml in " + path); XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}}); xmlNodeSetPtr nodes = xpath.Nodes(reinterpret_cast<const xmlChar*>(gRootfilesXPath)); if ( nodes == nullptr || nodes->nodeNr == 0 ) throw std::invalid_argument(std::string(__PRETTY_FUNCTION__) + ": No rootfiles in " + path); for ( int i = 0; i < nodes->nodeNr; i++ ) { xmlNodePtr n = nodes->nodeTab[i]; const xmlChar * _type = xmlGetProp(n, reinterpret_cast<const xmlChar*>("media-type")); std::string type((_type == nullptr ? "" : reinterpret_cast<const char*>(_type))); const xmlChar * _path = xmlGetProp(n, reinterpret_cast<const xmlChar*>("full-path")); if ( _path == nullptr ) continue; _packages.push_back(new Package(_archive, _path, type)); } LoadEncryption();}
开发者ID:jalal70,项目名称:readium-sdk,代码行数:34,
示例12: isScheduledWorkUnitbool isScheduledWorkUnit(char const * wuid){ Owned<IRemoteConnection> conn = querySDS().connect("/Schedule", myProcessSession(), RTM_LOCK_WRITE | RTM_CREATE_QUERY, connectionTimeout); StringBuffer xpath("*/*/*/"); ncnameEscape(wuid, xpath); return conn->queryRoot()->hasProp(xpath.str());}
开发者ID:AttilaVamos,项目名称:HPCC-Platform,代码行数:7,
示例13: expandManifestDirectoryvoid expandManifestDirectory(IPropertyTree *manifestSrc, IPropertyTree &res, StringBuffer &dir, IDirectoryIterator *it, const char*mask, bool recursive){ if (!it) return; ForEach(*it) { if (it->isDir()) { if (recursive) expandManifestDirectory(manifestSrc, res, dir, it->query().directoryFiles(mask, false, true), mask, recursive); continue; } StringBuffer reldir; Owned<IPropertyTree> newRes = createPTreeFromIPT(&res); reldir.append(splitRelativePath(it->query().queryFilename(), dir, reldir)); VStringBuffer xpath("Resource[@filename='%s']", reldir.str()); if (manifestSrc->hasProp(xpath)) continue; newRes->setProp("@filename", reldir.str()); updateManifestResourcePaths(*newRes, dir.str()); if (manifestSrc->hasProp(xpath.setf("resource[@resourcePath='%s']", newRes->queryProp("@resourcePath")))) continue; manifestSrc->addPropTree("Resource", newRes.getClear()); }}
开发者ID:hhy5277,项目名称:HPCC-Platform,代码行数:25,
示例14: listPkgInfovoid listPkgInfo(double version, const char *target, const char *process, const IPropertyTree* packageMaps, IPropertyTree* pkgSetRegistry, IArrayOf<IConstPackageListMapData>* results){ StringBuffer xpath("PackageMap"); if (target && *target) xpath.appendf("[@querySet='%s']", target); Owned<IPropertyTreeIterator> iter = pkgSetRegistry->getElements(xpath.str()); ForEach(*iter) { IPropertyTree &item = iter->query(); const char *id = item.queryProp("@id"); if (!id || !*id) continue; StringBuffer xpath; xpath.append("PackageMap[@id='").append(id).append("']"); IPropertyTree *mapTree = packageMaps->queryPropTree(xpath); if (!mapTree) continue; Owned<IEspPackageListMapData> res = createPackageListMapData("", ""); res->setActive(item.getPropBool("@active")); if (process && *process && (version >= 1.01)) res->setProcess(process); getPackageListInfo(mapTree, res); if (target && *target) res->setTarget(target); else res->setTarget(item.queryProp("@querySet")); results->append(*res.getClear()); }}
开发者ID:ruidafu,项目名称:HPCC-Platform,代码行数:31,
示例15: makeAbsolutePathbool ResourceManifest::loadInclude(IPropertyTree &include, const char *dir){ const char *filename = include.queryProp("@filename"); StringBuffer includePath; makeAbsolutePath(filename, dir, includePath); VStringBuffer xpath("Include[@originalFilename='%s']", includePath.str()); if (manifest->hasProp(xpath.str())) return false; include.setProp("@originalFilename", includePath.str()); StringBuffer includeDir; splitDirTail(includePath, includeDir); Owned<IPropertyTree> manifestInclude = createPTreeFromXMLFile(includePath.str()); Owned<IPropertyTreeIterator> it = manifestInclude->getElements("*"); ForEach(*it) { IPropertyTree &item = it->query(); if (streq(item.queryName(), "Resource")) updateResourcePaths(item, includeDir.str()); else if (streq(item.queryName(), "Include")) { if (!loadInclude(item, includeDir.str())) continue; } manifest->addPropTree(item.queryName(), LINK(&item)); } return true;}
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:30,
示例16: test_interfacevoid test_interface( std::istringstream& iss, const char *root ){ { config c; comma::read< config >( c, iss, root ); SCOPED_TRACE( "comma::read< config >( c, iss, root )" ); test_config( c ); } { config c; comma::read< config >( c, iss, root, true ); SCOPED_TRACE( "comma::read< config >( c, iss, root, true )" ); test_config( c ); } { config c; comma::read< config >( c, iss, xpath( root ) ); SCOPED_TRACE( "comma::read< config >( c, iss, xpath( root ) )" ); test_config( c ); } { config c; comma::read< config >( c, iss, xpath( root ), true ); SCOPED_TRACE( "comma::read< config >( c, iss, xpath( root ), true )" ); test_config( c ); } { config c = comma::read< config >( iss, root ); SCOPED_TRACE( "comma::read< config >( iss, root )" ); test_config( c ); } { config c = comma::read< config >( iss, root, true ); SCOPED_TRACE( "comma::read< config >( iss, root, true )" ); test_config( c ); } { config c = comma::read< config >( iss, xpath( root ) ); SCOPED_TRACE( "comma::read< config >( iss, xpath( root ) )" ); test_config( c ); } { config c = comma::read< config >( iss, xpath( root ), true ); SCOPED_TRACE( "comma::read< config >( iss, xpath( root ), true )" ); test_config( c ); }}
开发者ID:sheenzhaox,项目名称:comma,代码行数:47,
示例17: namebool NavigationTable::ParseXML(xmlNodePtr node){ if ( node == nullptr ) return false; string name(node->name); if ( AllowedRootNodeNames.find(name) == AllowedRootNodeNames.end() ) return false; _type = _getProp(node, "type", ePub3NamespaceURI); if ( _type.empty() ) return false;#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS) XPathWrangler xpath(node->doc, {{"epub", ePub3NamespaceURI}}); // goddamn I love C++11 initializer list constructors#else XPathWrangler::NamespaceList __ns; __ns["epub"] = ePub3NamespaceURI; XPathWrangler xpath(node->doc, __ns);#endif xpath.NameDefaultNamespace("html"); // look for optional <h2> title // Q: Should we fail on finding multiple <h2> tags here? auto strings = xpath.Strings("./html:h2[1]/text()", node); if ( !strings.empty() ) _title = std::move(strings[0]); // load List Elements from a single Ordered List // first: confirm there's a single list xmlNodeSetPtr nodes = xpath.Nodes("./html:ol", node); if ( nodes == nullptr ) return false; if ( nodes->nodeNr != 1 ) { xmlXPathFreeNodeSet(nodes); return false; } LoadChildElements(std::enable_shared_from_this<NavigationTable>::shared_from_this(), nodes->nodeTab[0]); xmlXPathFreeNodeSet(nodes); return true;}
开发者ID:becka11y,项目名称:readium-sdk,代码行数:46,
示例18: appendManifestResultSchema void appendManifestResultSchema(IPropertyTree &manifest, const char *resultname, ILoadedDllEntry &loadedDll) { assertex(!finalized); VStringBuffer xpath("Resource[@name='%s'][@type='RESULT_XSD']", resultname); IPropertyTree *res=manifest.queryPropTree(xpath.str()); if (res) appendSchemaResource(*res, loadedDll); }
开发者ID:Mandar-Shinde,项目名称:HPCC-Platform,代码行数:8,
示例19: xpathstring Package::PackageID() const{ XPathWrangler xpath(_opf, {{"opf", OPFNamespace}, {"dc", DCNamespace}}); XPathWrangler::StringList strings = xpath.Strings("//*[@id=/opf:package/@unique-identifier]/text()"); if ( strings.empty() ) return string::EmptyString; return strings[0];}
开发者ID:jalal70,项目名称:readium-sdk,代码行数:8,
示例20: sharedThisbool Container::Open(const string& path){ ContainerPtr sharedThis(shared_from_this()); _archive = std::move(Archive::Open(path.stl_str())); if ( _archive == nullptr ) throw std::invalid_argument(_Str("Path does not point to a recognised archive file: '", path, "'")); // TODO: Initialize lazily? Doing so would make initialization faster, but require // PackageLocations() to become non-const, like Packages(). ArchiveXmlReader reader(_archive->ReaderAtPath(gContainerFilePath)); _ocf = reader.xmlReadDocument(gContainerFilePath, nullptr, XML_PARSE_RECOVER|XML_PARSE_NOENT|XML_PARSE_DTDATTR); if ( _ocf == nullptr ) return false;#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS) XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}});#else XPathWrangler::NamespaceList __ns; __ns["ocf"] = OCFNamespaceURI; XPathWrangler xpath(_ocf, __ns);#endif xmlNodeSetPtr nodes = xpath.Nodes(reinterpret_cast<const xmlChar*>(gRootfilesXPath)); if ( nodes == nullptr || nodes->nodeNr == 0 ) return false; for ( int i = 0; i < nodes->nodeNr; i++ ) { xmlNodePtr n = nodes->nodeTab[i]; const xmlChar * _type = xmlGetProp(n, reinterpret_cast<const xmlChar*>("media-type")); std::string type((_type == nullptr ? "" : reinterpret_cast<const char*>(_type))); const xmlChar * _path = xmlGetProp(n, reinterpret_cast<const xmlChar*>("full-path")); if ( _path == nullptr ) continue; auto pkg = std::make_shared<Package>(sharedThis, type); if ( pkg->Open(_path) ) _packages.push_back(pkg); } LoadEncryption(); return true;}
开发者ID:becka11y,项目名称:readium-sdk,代码行数:45,
示例21: init void init() { VStringBuffer xpath("PackageMap[@id='%s']", pmid.str()); globalLock.setown(querySDS().connect("/PackageMaps", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT)); packageMaps = globalLock->queryRoot(); pmExisting = packageMaps->queryPropTree(xpath); if (pmExisting && !pmExisting->getPropBool("@multipart", false)) convertExisting(); }
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:9,
示例22: nodeArr/* long GetDocUrlDistance (in nsIDOMDocument doc); */NS_IMETHODIMP nsDomAttUtil::GetDocUrlDistance(nsIDOMDocument *doc, PRInt32 *_retval ){ nsresult rv; nsCOMPtr<nsIXpathUtil> xpathUtil=do_CreateInstance("@nyapc.com/XPCOM/nsXpathUtil;1",&rv); if (NS_FAILED(rv)) { return rv; } Distance ld; PRInt32 distValue=0; xpathUtil->SetDocument(doc); nsCOMPtr<nsISupportsArray> nodeArr(nsnull); nsCString xpath("//a[@href]"); xpathUtil->GetNodes(xpath, getter_AddRefs(nodeArr)); if(nodeArr!=nsnull) { PRUint32 arrlen=0; nodeArr->Count(&arrlen); std::string lastUrl; bool setinit=false; for(PRUint32 i=0;i<arrlen;i++) { nsCOMPtr<nsISupports> node; nodeArr->GetElementAt(i,getter_AddRefs(node)); nsCOMPtr<nsIDOMElement> domele=do_QueryInterface(node); nsString nsName=NS_ConvertUTF8toUTF16("href"); nsString nsValue; if(domele!=nsnull) { domele->GetAttribute(nsName,nsValue); if(!setinit) { lastUrl=std::string(NS_ConvertUTF16toUTF8(nsValue).get()); setinit=true; } else { std::string curUrl(NS_ConvertUTF16toUTF8(nsValue).get()); distValue+=ld.LD(lastUrl,curUrl); lastUrl=curUrl; } } } *_retval=distValue; } else { *_retval=-1; } return NS_OK;}
开发者ID:firememory,项目名称:dfwbi,代码行数:57,
示例23: xpathstring Container::Version() const{ XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}}); std::vector<string> strings = xpath.Strings(gVersionXPath); if ( strings.empty() ) return "1.0"; // guess return std::move(strings[0]);}
开发者ID:jalal70,项目名称:readium-sdk,代码行数:10,
示例24: pvoid p(cspider_t *cspider, char *d, char *url, void *user_data) { char *get[10]; int size = xpath(d, "//a/@href", get, 10);// int size = regexAll("http://////(.*?)//.html", d, get, 3, REGEX_ALL); cspider_joinall(url,get,size); addUrls(cspider, get, size); saveStrings(cspider, (void**)get, size, LOCK); freeStrings(get, size);}
开发者ID:rim99,项目名称:CSpider,代码行数:10,
示例25: ifNode Node::select(const std::string& selector,const std::string& type) const { std::string xpat; if(type=="css") xpat = xpath(selector); else if(type=="xpath") xpat = selector; else STENCILA_THROW(Exception,"Unknown selector type <"+type+">"); try { return pimpl_->select_single_node(xpat.c_str()).node(); } catch (const pugi::xpath_exception& e){ STENCILA_THROW(Exception,e.what()); }}
开发者ID:codeaudit,项目名称:stencila,代码行数:11,
示例26: headxpath xpath::head() const{ if( *this == xpath( "/" ) ) { return *this; } xpath x; if( elements.size() > 1 ) { x.elements.resize( elements.size() - 1 ); for( std::size_t i = 0; i < x.elements.size(); ++i ) { x.elements[i] = elements[i]; } } return x;}
开发者ID:sheenzhaox,项目名称:comma,代码行数:11,
示例27: makeAbsolutePathvoid ResourceManager::addManifestInclude(IPropertyTree &include, const char *dir){ StringBuffer includePath; makeAbsolutePath(include.queryProp("@filename"), dir, includePath); VStringBuffer xpath("Include[@originalFilename='%s']", includePath.str()); if (manifest->hasProp(xpath.str())) return; include.setProp("@originalFilename", includePath.str()); manifest->addPropTree("Include", LINK(&include)); addManifestFile(includePath.str());}
开发者ID:hhy5277,项目名称:HPCC-Platform,代码行数:11,
示例28: MakeStringException IPropertyTree *ensurePart(const char *partname) { if (!pmExisting) throw MakeStringException(PKG_NAME_EXISTS, "PackageMap %s not found", pmid.str()); VStringBuffer xpath("Part[@id='%s']", partname); IPropertyTree *existingPart = pmExisting->queryPropTree(xpath); if (!existingPart) throw MakeStringException(PKG_NAME_EXISTS, "PackageMap %s Part %s not found", pmid.str(), partname); return existingPart; }
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:11,
示例29: NavigationListNavigationList PackageBase::NavTablesFromManifestItem(shared_ptr<PackageBase> owner, shared_ptr<ManifestItem> pItem){ PackagePtr sharedPkg = std::dynamic_pointer_cast<Package>(owner); if ( !sharedPkg ) return NavigationList(); if ( pItem == nullptr ) return NavigationList(); xmlDocPtr doc = pItem->ReferencedDocument(); if ( doc == nullptr ) return NavigationList(); // find each <nav> node#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS) XPathWrangler xpath(doc, {{"epub", ePub3NamespaceURI}}); // goddamn I love C++11 initializer list constructors#else XPathWrangler::NamespaceList __m; __m["epub"] = ePub3NamespaceURI; XPathWrangler xpath(doc, __m);#endif xpath.NameDefaultNamespace("html"); xmlNodeSetPtr nodes = xpath.Nodes("//html:nav"); NavigationList tables; for ( int i = 0; i < nodes->nodeNr; i++ ) { xmlNodePtr navNode = nodes->nodeTab[i]; auto navTablePtr = std::make_shared<class NavigationTable>(sharedPkg, pItem->Href()); if ( navTablePtr->ParseXML(navNode) ) tables.push_back(navTablePtr); } xmlXPathFreeNodeSet(nodes); // now look for any <dl> nodes with an epub:type of "glossary" nodes = xpath.Nodes("//html:dl[epub:type='glossary']"); return tables;}
开发者ID:becka11y,项目名称:readium-sdk,代码行数:41,
注:本文中的xpath函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xprintf函数代码示例 C++ xp函数代码示例 |