本文整理汇总了C++中DOMElement::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::getAttributes方法的具体用法?C++ DOMElement::getAttributes怎么用?C++ DOMElement::getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseGameObjectFile
void XmlPropertyReader::parseGameObjectFile(Ogre::DataStreamPtr &stream, const Ogre::String &groupName)
{
initializeXml();
XERCES_CPP_NAMESPACE::DOMDocument* doc = loadDocument(stream);
DOMNodeList* godefsXml = doc->getDocumentElement()->getElementsByTagName(AutoXMLCh("gameobjectclass").data());
for (unsigned int idx = 0; idx < godefsXml->getLength(); idx++)
{
PropertyRecordPtr ps(new PropertyRecord());
DOMElement* curNode = static_cast<DOMElement*>(godefsXml->item(idx));
const DOMNamedNodeMap* godefAttrs = curNode->getAttributes();
for (XMLSize_t attrIdx = 0; attrIdx < godefAttrs->getLength(); attrIdx++)
{
PropertyEntry entry = processProperty(static_cast<DOMAttr*>(godefAttrs->item(attrIdx)));
if (entry.first != "")
{
ps->setProperty(entry.first, entry.second);
}
}
DOMNodeList* godefChildren = curNode->getChildNodes();
for (XMLSize_t childIdx = 0; childIdx < godefChildren->getLength(); childIdx++)
{
DOMNode* curChild = godefChildren->item(childIdx);
if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
{
PropertyEntry entry = processProperty(static_cast<DOMElement*>(curChild));
if (entry.first != "")
{
ps->setProperty(entry.first, entry.second);
}
}
}
mPropertyRecords.push_back(ps);
}
shutdownXml();
}
示例2:
// ---------------------------------------------------------------------------
// utility func to extract a DOMNodes Base attr value if present
// ---------------------------------------------------------------------------
static const XMLCh *
getBaseAttrValue(DOMNode *node){
if (node->getNodeType() == DOMNode::ELEMENT_NODE){
DOMElement *elem = (DOMElement *)node;
if(elem->hasAttributes()) {
/* get all the attributes of the node */
DOMNamedNodeMap *pAttributes = elem->getAttributes();
XMLSize_t nSize = pAttributes->getLength();
for(XMLSize_t i=0;i<nSize;++i) {
DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
/* get attribute name */
if (XMLString::equals(pAttributeNode->getName(), XIncludeUtils::fgXIBaseAttrName)){
/*if (namespace == XMLUni::fgXMLString){
}*/
return pAttributeNode->getValue();
}
}
}
}
return NULL;
}
示例3: getConfigAttributeNames
Triggerconf::STRING_LIST Triggerconf::getConfigAttributeNames (string module, string submodule, string configname)
{
STRING_LIST ret;
if (! existsConfigElement (module, submodule, configname)) return ret;
DOMNode* node = selectConfigElement (module, submodule, configname);
if (node == NULL || node->getNodeType () != DOMNode::ELEMENT_NODE) return ret;
DOMElement* elem = (DOMElement*) node;
DOMNamedNodeMap* attributes = elem->getAttributes ();
for (unsigned int i=0; i<attributes->getLength (); i++) {
DOMNode* attr = attributes->item (i);
const XMLCh* xname = attr->getNodeName ();
char* cname = XMLString::transcode (xname);
ret.push_back (cname);
XMLString::release (&cname);
}
return ret;
}
示例4: DeltaReverse
DOMNode* DeltaReverse( DOMNode *deltaElement, DOMDocument *reversedDoc ) {
vddprintf((" reversing time-version header\n"));
DOMNode* reversedElement = reversedDoc->importNode( deltaElement, false );
//DOMString from = deltaElement.getAttributes().getNamedItem("from").getNodeValue() ;
//DOMString to = deltaElement.getAttributes().getNamedItem("to" ).getNodeValue() ;
const XMLCh* from = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("from"))->getNodeValue() ;
const XMLCh* to = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("to"))->getNodeValue() ;
reversedElement->getAttributes()->getNamedItem(XMLString::transcode("to"))->setNodeValue( from );
reversedElement->getAttributes()->getNamedItem(XMLString::transcode("from"))->setNodeValue( to );
DOMNode* fromXidMap = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("fromXidMap"));
DOMNode* toXidMap = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("toXidMap"));
if (fromXidMap!=NULL) {
//DOMString from = fromXidMap.getNodeValue();
reversedElement->getAttributes()->getNamedItem(XMLString::transcode("toXidMap"))->setNodeValue( fromXidMap->getNodeValue() );
}
if (toXidMap!=NULL) {
//DOMString to = toXidMap.getNodeValue();
reversedElement->getAttributes()->getNamedItem(XMLString::transcode("fromXidMap"))->setNodeValue( toXidMap->getNodeValue() );
}
// No chanhges in the delta -> ok
if (!deltaElement->hasChildNodes()) return( reversedElement );
// Input : read Elementary Operation
DOMNode* child = deltaElement->getFirstChild() ;
// Output : precedent will be used to write Elementary Operation in reverse order
DOMNode* precedent = NULL; // =NULL by default
while (child != NULL) {
if (child->getNodeType()!=DOMNode::ELEMENT_NODE) THROW_AWAY(("Bad type (%d) for Delta Operation Node", (int)child->getNodeType()));
DOMElement* operationNode = (DOMElement*) child ;
XyLatinStr operation(child->getLocalName());
// Reverse DELETE into INSERT
if (strcmp(operation, "d")==0) {
vddprintf((" reversing delete into insert\n"));
DOMElement* iElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:i")) ;
CopyAttr(iElement, operationNode, XMLString::transcode("par"), true);
CopyAttr(iElement, operationNode, XMLString::transcode("pos"), true);
CopyAttr(iElement, operationNode, XMLString::transcode("xm"), true);
CopyAttr(iElement, operationNode, XMLString::transcode("move"), false);
CopyAttr(iElement, operationNode, XMLString::transcode("update"), false);
CopyContent(iElement, operationNode);
reversedElement->insertBefore( iElement, precedent ) ;
precedent = iElement ;
}
// Reverse INSERT into DELETE
else if (strcmp(operation, "i")==0) {
vddprintf((" reversing insert into delete\n"));
DOMElement *iElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:d")) ;
CopyAttr(iElement, operationNode, XMLString::transcode("par"), true);
CopyAttr(iElement, operationNode, XMLString::transcode("pos"), true);
CopyAttr(iElement, operationNode, XMLString::transcode("xm"), true);
CopyAttr(iElement, operationNode, XMLString::transcode("move"), false);
CopyAttr(iElement, operationNode, XMLString::transcode("update"), false);
CopyContent(iElement, operationNode);
reversedElement->insertBefore( iElement, precedent ) ;
precedent = iElement ;
}
// Attribute Update
else if (strcmp(operation, "au")==0) {
vddprintf((" reversing attribute update\n"));
//DOMString xidElem = operationNode.getAttributes().getNamedItem("xid").getNodeValue();
//DOMString attrName = operationNode.getAttributes().getNamedItem("a").getNodeValue();
//DOMString oldValue = operationNode.getAttributes().getNamedItem("ov").getNodeValue();
//DOMString newValue = operationNode.getAttributes().getNamedItem("nv").getNodeValue();
const XMLCh* xidElem = operationNode->getAttributes()->getNamedItem(XMLString::transcode("xid"))->getNodeValue();
const XMLCh* attrName = operationNode->getAttributes()->getNamedItem(XMLString::transcode("a"))->getNodeValue();
const XMLCh* oldValue = operationNode->getAttributes()->getNamedItem(XMLString::transcode("ov"))->getNodeValue();
const XMLCh* newValue = operationNode->getAttributes()->getNamedItem(XMLString::transcode("nv"))->getNodeValue();
DOMElement* auElement = reversedDoc->createElementNS(XYDIFF_XYDELTA_NS, XMLString::transcode("xy:au"));
auElement->setAttribute(XMLString::transcode("xid"), xidElem);
auElement->setAttribute(XMLString::transcode("a"), attrName);
auElement->setAttribute(XMLString::transcode("nv"), oldValue);
auElement->setAttribute(XMLString::transcode("ov"), newValue);
reversedElement->insertBefore(auElement, precedent);
precedent = auElement ;
}
// Attribute Delete
else if (strcmp(operation, "ad")==0) {
vddprintf((" reversing attribute insert into attribute delete\n"));
//DOMString xidElem = operationNode.getAttributes().getNamedItem("xid").getNodeValue();
//DOMString attrName = operationNode.getAttributes().getNamedItem("a").getNodeValue();
//DOMString attrVal = operationNode.getAttributes().getNamedItem("v").getNodeValue();
const XMLCh* xidElem = operationNode->getAttributes()->getNamedItem(XMLString::transcode("xid"))->getNodeValue();
const XMLCh* attrName = operationNode->getAttributes()->getNamedItem(XMLString::transcode("a"))->getNodeValue();
//.........这里部分代码省略.........