本文整理汇总了C++中poco::xml::Node类的典型用法代码示例。如果您正苦于以下问题:C++ Node类的具体用法?C++ Node怎么用?C++ Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InvalidArgumentException
Poco::XML::Node* XMLConfiguration::findElement(int index, Poco::XML::Node* pNode, bool create)
{
Poco::XML::Node* pRefNode = pNode;
if (index > 0)
{
pNode = pNode->nextSibling();
while (pNode)
{
if (pNode->nodeName() == pRefNode->nodeName())
{
if (--index == 0) break;
}
pNode = pNode->nextSibling();
}
}
if (!pNode && create)
{
if (index == 1)
{
Poco::AutoPtr<Poco::XML::Element> pElem = pRefNode->ownerDocument()->createElement(pRefNode->nodeName());
pRefNode->parentNode()->appendChild(pElem);
return pElem;
}
else throw Poco::InvalidArgumentException("Element index out of range.");
}
return pNode;
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:27,代码来源:XMLConfiguration.cpp
示例2: get_text_from_tag
std::string XmlHandler::get_text_from_tag(const std::string &xpath) {
Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT);
Poco::XML::Node *pNode = it.nextNode();
Poco::XML::Node *detectorNode = pNode->getNodeByPath(xpath);
std::string value;
if (detectorNode)
value = detectorNode->innerText();
return value;
}
示例3: remove
void ofXml::remove(){
Poco::XML::Node * parent = element->parentNode();
if(parent){
parent->removeChild(element);
element->release();
element = (Poco::XML::Element*)parent;
}else{
clear();
}
}
示例4: getFirstElementAtPathInnerText
std::string XMLParserPoco::getFirstElementAtPathInnerText(std::string path)
{
if(_documentLoaded)
{
Poco::XML::Node* node = _document->getNodeByPath(path);
if(node != nullptr)
{
return node->innerText();
}
}
return "";
}
示例5: setRaw
void XMLConfiguration::setRaw(const std::string& key, const std::string& value)
{
std::string::const_iterator it = key.begin();
Poco::XML::Node* pNode = findNode(it, key.end(), _pRoot, true);
if (pNode)
{
unsigned short nodeType = pNode->nodeType();
if (Poco::XML::Node::ATTRIBUTE_NODE == nodeType)
{
pNode->setNodeValue(value);
}
else if (Poco::XML::Node::ELEMENT_NODE == nodeType)
{
Poco::XML::Node* pChildNode = pNode->firstChild();
if (pChildNode)
{
if (Poco::XML::Node::TEXT_NODE == pChildNode->nodeType())
{
pChildNode->setNodeValue(value);
}
}
else
{
Poco::AutoPtr<Poco::XML::Node> pText = _pDocument->createTextNode(value);
pNode->appendChild(pText);
}
}
}
else throw NotFoundException("Node not found in XMLConfiguration", key);
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:30,代码来源:XMLConfiguration.cpp
示例6: it
/**
* Returns list of sub-nodes for a xpath node
* For: xpath = //Data/
* Returns: Detector , DetectorWing
*/
std::vector<std::string> XmlHandler::get_subnodes(const std::string &xpath) {
std::vector<std::string> subnodes;
Poco::XML::Node *xpathNode = pDoc->getNodeByPath(xpath);
Poco::XML::NodeIterator it(xpathNode, Poco::XML::NodeFilter::SHOW_ELEMENT);
Poco::XML::Node *pNode = it.nextNode();
while (pNode) {
if (pNode->childNodes()->length() == 1) {
subnodes.push_back(pNode->nodeName());
}
pNode = it.nextNode();
}
return subnodes;
}
示例7:
Poco::XML::Node* XMLConfiguration::findElement(const std::string& name, Poco::XML::Node* pNode, bool create)
{
Poco::XML::Node* pChild = pNode->firstChild();
while (pChild)
{
if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE && pChild->nodeName() == name)
return pChild;
pChild = pChild->nextSibling();
}
if (create)
{
Poco::AutoPtr<Poco::XML::Element> pElem = pNode->ownerDocument()->createElement(name);
pNode->appendChild(pElem);
return pElem;
}
else return 0;
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:17,代码来源:XMLConfiguration.cpp
示例8: removeContents
bool ofXml::removeContents() {
if(element && element->hasChildNodes())
{
Poco::XML::Node* swap;
Poco::XML::Node* n = element->firstChild();
while(n->nextSibling() != nullptr)
{
swap = n->nextSibling();
element->removeChild(n);
n = swap;
}
return true;
}
return false;
}
示例9: getNetWorkPathAttr
void Configure::getNetWorkPathAttr(Poco::XML::NamedNodeMap* map, struct NetworkPathInfo* info)
{
if(map)//看看是否真有属性
{
for(int i = 0 ; i < map->length() ; i++)//属性肯定至少0个,用循环一个个取出
{
Poco::XML::Node* attr = map->item(i);
if(attr->nodeName() == "UserName")
{
info->username = attr->nodeValue();
}
else if(attr->nodeName() == "Password")
{
info->password = attr->nodeValue();
}
}//属性结束
}
}
示例10: getAttributeValueByName
/*
* Get attribute's value by name from a Node
*/
std::string LoadGroupXMLFile::getAttributeValueByName(Poco::XML::Node *pNode,
std::string attributename,
bool &found) {
// 1. Init
Poco::AutoPtr<Poco::XML::NamedNodeMap> att = pNode->attributes();
found = false;
std::string value = "";
// 2. Loop to find
for (unsigned long i = 0; i < att->length(); ++i) {
Poco::XML::Node *cNode = att->item(i);
if (cNode->localName().compare(attributename) == 0) {
value = cNode->getNodeValue();
found = true;
break;
}
} // ENDFOR
return value;
}
示例11: removeRaw
void XMLConfiguration::removeRaw(const std::string& key)
{
Poco::XML::Node* pNode = findNode(key);
if (pNode)
{
if (pNode->nodeType() == Poco::XML::Node::ELEMENT_NODE)
{
Poco::XML::Node* pParent = pNode->parentNode();
if (pParent)
{
pParent->removeChild(pNode);
}
}
else if (pNode->nodeType() == Poco::XML::Node::ATTRIBUTE_NODE)
{
Poco::XML::Attr* pAttr = dynamic_cast<Poco::XML::Attr*>(pNode);
Poco::XML::Element* pOwner = pAttr->ownerElement();
if (pOwner)
{
pOwner->removeAttributeNode(pAttr);
}
}
}
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:25,代码来源:XMLConfiguration.cpp
示例12: getAttribute
string ofXml::getAttribute(const string& path) const {
Poco::XML::Node *e;
if(element) {
if(path.find("[@") == string::npos) {
// we need to create a proper path
string attributePath = "[@" + path + "]";
e = element->getNodeByPath(attributePath);
} else {
e = element->getNodeByPath(path);
}
} else {
ofLogWarning("ofXml") << "getAttribute(): no element set yet";
return "";
}
if(e) {
return e->getNodeValue(); // this will be the value of the attribute
}
return "";
}
示例13: loadChannelList
void Configure::loadChannelList(void)
{
std::ifstream in(SystemInfo::instance().getExecutePath() + "\\config\\channelList.xml");
Poco::XML::InputSource src(in);
Poco::XML::DOMParser parser;
try
{
Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&src);
Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ALL);
Poco::XML::Node* pNode = it.nextNode();
static int index = 0;
std::string channelInfo[3];
while (pNode)
{
if(pNode->nodeName() == "Row")
{
pNode = it.nextNode();
if(pNode->nodeName() != "#text")
{
continue; //No text node present
}
index = 0;
if(m_encodeChannel == channelInfo[1])
{
// 找到频道对照表
m_encodeChannelID = channelInfo[0];
m_encodeChannelPrefix = channelInfo[2];
LOG(INFO) << "get channel info : ID [" << m_encodeChannelID << "] Prefix[" << m_encodeChannelPrefix << "].";
return;
}
}
if(pNode->nodeName() == "Cell")
{
pNode = it.nextNode();
if(pNode->nodeName() != "#text")
{
pNode = it.nextNode();
continue; //No text node present
}
channelInfo[index++] = pNode->nodeValue();
}
pNode = it.nextNode();//指向下一个node
}
}
catch(std::exception& e)
{
LOG(ERROR) << "parse channelList xml file error." << e.what() ;
}
}
示例14: getOutputStreamAttr
void Configure::getOutputStreamAttr(Poco::XML::NamedNodeMap* map, struct OutputStream* outputstream)
{
if(map)//看看是否真有属性
{
for(int i = 0 ; i < map->length() ; i++)//属性肯定至少0个,用循环一个个取出
{
Poco::XML::Node* attr = map->item(i);
if(attr->nodeName() == "Enable")
{
outputstream->enable = attr->nodeValue();
}
else if(attr->nodeName() == "BitRate")
{
outputstream->bitrate = attr->nodeValue();
}
else if(attr->nodeName() == "ResolutionRatio")
{
outputstream->resolutionRatio = attr->nodeValue();
}
}//属性结束
}
}
示例15: svgtiny_parse_text
svgtiny_code svgtiny_parse_text(Poco::XML::Element *text,
struct svgtiny_parse_state state)
{
float x, y, width, height;
float px, py;
Poco::XML::Element *child;
svgtiny_parse_position_attributes(text, state,
&x, &y, &width, &height);
svgtiny_parse_font_attributes(text, &state);
svgtiny_parse_transform_attributes(text, &state);
px = state.ctm.a * x + state.ctm.c * y + state.ctm.e;
py = state.ctm.b * x + state.ctm.d * y + state.ctm.f;
/* state.ctm.e = px - state.origin_x; */
/* state.ctm.f = py - state.origin_y; */
/*struct css_style style = state.style;
style.font_size.value.length.value *= state.ctm.a;*/
//for (child = text->children; child; child = child->next) {
//for( child = (Poco::XML::Element*) text->FirstChild( false ); child; child = (Poco::XML::Element*) child->NextSibling( false ) ) {
Poco::XML::NodeIterator it(text, Poco::XML::NodeFilter::SHOW_ELEMENT | Poco::XML::NodeFilter::SHOW_TEXT);
Poco::XML::Node* pNode = it.nextNode();
while (pNode) {
svgtiny_code code = svgtiny_OK;
if (pNode->getNodeValue().compare("text") == 0)
{
struct svgtiny_shape *shape = svgtiny_add_shape(&state);
if (!shape)
return svgtiny_OUT_OF_MEMORY;
//shape->text = strdup((const char *) child->content);
shape->text = strdup((const char *) pNode->getNodeValue().c_str());
shape->text_x = px;
shape->text_y = py;
state.diagram->shape_count++;
}
//else if (strcmp((const char *) child->Value(), "tspan") == 0)
else if (pNode->getNodeValue().compare("tspan") == 0)
{
code = svgtiny_parse_text(child, state);
}
pNode = it.nextNode();
if (code == svgtiny_OK)
return code;
}
return svgtiny_OK;
}