本文整理汇总了C++中xml_node::remove_child方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::remove_child方法的具体用法?C++ xml_node::remove_child怎么用?C++ xml_node::remove_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml_node
的用法示例。
在下文中一共展示了xml_node::remove_child方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processNode
void Editor_Html2Usfm::processNoteCitation (xml_node node)
{
// Remove the note citation from the text.
// It means that this:
// <a href="#note1" id="citation1" class="superscript">x</a>
// becomes this:
// <a href="#note1" id="citation1" class="superscript" />
xml_node child = node.first_child ();
node.remove_child (child);
// Get more information about the footnote to retrieve.
string href = node.attribute ("href").value ();
string id = href.substr (1);
// Sample footnote body.
// <p class="x"><a href="#citation1" id="note1">x</a><span> </span><span>+ 2 Joh. 1.1</span></p>
// Retrieve the <a> element from it.
// At first this was done through an XPath expression:
// http://www.grinninglizard.com/tinyxml2docs/index.html
// But XPath crashes on Android with libxml2.
// Therefore now it iterates of all the nodes to find the required <a> element.
// (After moving to pugixml, the XPath expression could have been used again, but this was not done.)
xml_node aElement = get_note_pointer (document.first_child (), id);
if (aElement) {
// It now has the 'a' element: Get its 'p' parent, and then remove that 'a' element.
// So we remain with:
// <p class="x"><span> </span><span>+ 2 Joh. 1.1</span></p>
xml_node pElement = aElement.parent ();
pElement.remove_child (aElement);
// Preserve active character styles in the main text, and reset them for the note.
vector <string> preservedCharacterStyles = characterStyles;
characterStyles.clear();
// Process this 'p' element.
processingNote = true;
processNode (pElement);
processingNote = false;
// Restore the active character styles for the main text.
characterStyles = preservedCharacterStyles;
// Remove this element so it can't be processed again.
xml_node div_notes = pElement.parent ();
div_notes.remove_child (pElement);
} else {
Database_Logs::log ("Discarding note with id " + id + " and href " + href);
}
}
示例2: ImportResource
void ImportResource(xml_node xmlNode, const tstring & strUiresDir,const tstring & strNamePrefix,xml_node xmlSkin)
{
WIN32_FIND_DATA fd;
HANDLE hContext = ::FindFirstFile((strUiresDir+_T("\\*.*")).c_str(), &fd);
if(hContext!=INVALID_HANDLE_VALUE)
{
while(::FindNextFile(hContext,&fd))
{
if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(_tcscmp(fd.cFileName,_T(".")) == 0 || _tcscmp(fd.cFileName,_T("..")) == 0)
continue;
ImportResource(xmlNode, strUiresDir+_T("\\")+ fd.cFileName, strNamePrefix+ fd.cFileName + _T("."),xmlSkin);
}else
{
xml_node newFile = xmlNode.append_child(_T("file"));
TCHAR szName[MAX_PATH],szExt[50];
_tsplitpath(fd.cFileName,NULL,NULL,szName,szExt);
tstring strName,strPath;
strName = strNamePrefix+szName;
strPath = strUiresDir + _T("\\") + fd.cFileName;
if(xmlSkin)
{
LPTSTR p = _tcsrchr(szName,'[');
{
if(p) *p = 0;
strName = strNamePrefix+szName;
tstring src = xmlNode.name();
src += _T(":");
src += strName;
xml_node node = xmlSkin.find_child_by_attribute(_T("name"),strName.c_str());
if(node) xmlSkin.remove_child(node);//自动使用新的皮肤替换原有皮肤。
int nStates=1, left=-1,top=-1,right=-1,bottom=-1;
int nValues = 0;
int nColorize = g_bEnableColorize?1:0, //着色标志 {ec=0/1}
nAutoFit = 1, //自适应标志{fit=0/1}
nTile = 0, //平铺标志{tile=0/1}
nVertical = 0, //子图垂直排列标志{vert=0/1}
nFilter=0; //绘制滤镜:{filter=0/1/2/3} 0=null,1=low,2=midium,3=high
if(p)
{
nValues = _stscanf(p+1,_T("%d{%d,%d,%d,%d}]"),&nStates,&left,&top,&right,&bottom);
LPCTSTR pszFind = _tcsstr(p+1,_T("{ec="));
if(pszFind) nColorize = _ttoi(pszFind+4);
pszFind = _tcsstr(p+1,_T("{fit="));
if(pszFind) nAutoFit = _ttoi(pszFind+5);
pszFind = _tcsstr(p+1,_T("{filter="));
if(pszFind) nFilter = _ttoi(pszFind+8);
pszFind = _tcsstr(p+1,_T("{tile="));
if(pszFind) nTile = _ttoi(pszFind+6);
pszFind = _tcsstr(p+1,_T("{vert="));
if(pszFind) nVertical = _ttoi(pszFind+6);
}
xml_node il = xmlSkin.append_child();
il.append_attribute(_T("name")).set_value(strName.c_str());
il.append_attribute(_T("src")).set_value(src.c_str());
il.append_attribute(_T("states")).set_value(nStates);
if(nValues==0 || nValues == 1)
{//imglist
il.set_name(_T("imglist"));
}else if(nValues==3 || nValues == 5)
{//imgframe
il.set_name(_T("imgframe"));
TCHAR szMargin[100];
_stprintf(szMargin,_T("%d,%d,%d,%d"),left,top,right==-1?left:right,bottom==-1?top:bottom);
il.append_attribute(_T("margin")).set_value(szMargin);
}
//设置各种可先属性
if(nColorize == 0) il.append_attribute(_T("enableColorize")).set_value(0);
if(nAutoFit == 0) il.append_attribute(_T("autoFit")).set_value(0);
if(nTile !=0 ) il.append_attribute(_T("tile")).set_value(1);
if(nVertical != 0 ) il.append_attribute(_T("vertical")).set_value(1);
switch(nFilter)
{
case 1:il.append_attribute(_T("filterLevel")).set_value(_T("low"));break;
case 2:il.append_attribute(_T("filterLevel")).set_value(_T("midium"));break;
case 3:il.append_attribute(_T("filterLevel")).set_value(_T("high"));break;
}
}
}
newFile.append_attribute(L"name").set_value(strName.c_str());
newFile.append_attribute(L"path").set_value(strPath.c_str());
}
}
::FindClose(hContext);
}
}