本文整理汇总了C++中poco::xml::DOMParser::setFeature方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMParser::setFeature方法的具体用法?C++ DOMParser::setFeature怎么用?C++ DOMParser::setFeature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::xml::DOMParser
的用法示例。
在下文中一共展示了DOMParser::setFeature方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uri
Poco::AutoPtr<Poco::XML::Document> Twitter::invoke(const std::string& httpMethod, const std::string& twitterMethod, Poco::Net::HTMLForm& form)
{
// Create the request URI.
// We use the XML version of the Twitter API.
Poco::URI uri(_uri + twitterMethod + ".xml");
std::string path(uri.getPath());
Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
Poco::Net::HTTPRequest req(httpMethod, path, Poco::Net::HTTPMessage::HTTP_1_1);
// Add username and password (HTTP basic authentication) to the request.
Poco::Net::HTTPBasicCredentials cred(_username, _password);
cred.authenticate(req);
// Send the request.
form.prepareSubmit(req);
std::ostream& ostr = session.sendRequest(req);
form.write(ostr);
// Receive the response.
Poco::Net::HTTPResponse res;
std::istream& rs = session.receiveResponse(res);
// Create a DOM document from the response.
Poco::XML::DOMParser parser;
parser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
Poco::XML::InputSource source(rs);
Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&source);
// If everything went fine, return the XML document.
// Otherwise look for an error message in the XML document.
if (res.getStatus() == Poco::Net::HTTPResponse::HTTP_OK)
{
return pDoc;
}
else
{
std::string error(res.getReason());
Poco::AutoPtr<Poco::XML::NodeList> pList = pDoc->getElementsByTagName("error");
if (pList->length() > 0)
{
error += ": ";
error += pList->item(0)->innerText();
}
throw Poco::ApplicationException("Twitter Error", error);
}
}
示例2: load
void XMLConfiguration::load(Poco::XML::InputSource* pInputSource)
{
poco_check_ptr (pInputSource);
Poco::XML::DOMParser parser;
parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
parser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
Poco::XML::AutoPtr<Poco::XML::Document> pDoc = parser.parse(pInputSource);
load(pDoc);
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:10,代码来源:XMLConfiguration.cpp
示例3: handleExtensions
void ExtensionPointService::handleExtensions(Bundle::ConstPtr pBundle, std::istream& istr, GenericHandler handler, Direction dir)
{
Poco::XML::DOMParser parser;
parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
parser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
Poco::XML::InputSource source(istr);
AutoPtr<Document> pDoc(parser.parse(&source));
Node* pRoot = pDoc->firstChild();
while (pRoot && pRoot->nodeName() != EXTENSIONS_ELEM)
{
pRoot = pRoot->nextSibling();
}
if (pRoot)
{
Node* pNode = (dir == DIR_FORWARD ? pRoot->firstChild() : pRoot->lastChild());
while (pNode)
{
if (pNode->nodeType() == Node::ELEMENT_NODE)
{
if (pNode->nodeName() == EXTENSION_ELEM)
{
Element* pElem = static_cast<Element*>(pNode);
const std::string& id = pElem->getAttribute(POINT_ATTR);
if (!id.empty())
{
(this->*handler)(pBundle, id, pElem);
}
else
{
_logger.error(std::string("No point attribute found in extension element of bundle ")
+ pBundle->symbolicName());
}
}
else
{
_logger.warning(std::string("Unsupported element '")
+ pNode->nodeName()
+ "' found in "
+ EXTENSIONS_XML
+ " of bundle "
+ pBundle->symbolicName());
}
}
pNode = (dir == DIR_FORWARD ? pNode->nextSibling() : pNode->previousSibling());
}
}
else throw Poco::NotFoundException("No extensions element found");
}