本文整理汇总了C++中IXMLDOMDocument::getElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocument::getElementsByTagName方法的具体用法?C++ IXMLDOMDocument::getElementsByTagName怎么用?C++ IXMLDOMDocument::getElementsByTagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXMLDOMDocument
的用法示例。
在下文中一共展示了IXMLDOMDocument::getElementsByTagName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readDatasetFile
int DicomImageSet::readDatasetFile(const QString &datasetFileName, QTreeWidget *treeWidget)
{
HRESULT hr = S_OK;
IXMLDOMDocument *pXMLDom = NULL;
IXMLDOMNodeList *pPatients = NULL;
IXMLDOMNode *pPatient = NULL;
DOMNodeType nodeType;
VARIANT_BOOL varStatus;
VARIANT varFileName;
VARIANT varValue;
BSTR bstrQuery;
VariantInit(&varFileName);
VariantInit(&varValue);
QString queryPatient, queryDate, queryProtocol, queryCollection;
CHK_HR(CreateAndInitDOM(&pXMLDom));
CHK_HR(VariantFromString(datasetFileName.toStdWString().c_str(), varFileName));
CHK_HR(pXMLDom->load(varFileName, &varStatus));
if (varStatus != VARIANT_TRUE)
{
CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml."));
}
treeWidget->clear();
treeWidget->setColumnCount(1);
CHK_HR(pXMLDom->getElementsByTagName(L"Patient", &pPatients));
if (pPatients)
{
long nPatients;
CHK_HR(pPatients->get_length(&nPatients));
for (long i=0; i<nPatients; ++i)
{
CHK_HR(pPatients->get_item(i, &pPatient));
CHK_HR(GetAttributeFromNode(pPatient, L"patients_name", &varValue));
queryPatient = QString::fromWCharArray(_bstr_t(varValue));
QTreeWidgetItem * patientItem = new QTreeWidgetItem(treeWidget, QStringList(queryPatient));
patientItem->setExpanded(true);
IXMLDOMNodeList * pDates = NULL;
CHK_HR(pPatient->get_childNodes(&pDates));
long nDates;
CHK_HR(pDates->get_length(&nDates));
for (long j=0; j<nDates; ++j)
{
IXMLDOMNode * pDate = NULL;
CHK_HR(pDates->get_item(j, &pDate));
CHK_HR(pDate->get_nodeType(&nodeType));
if(nodeType!=NODE_ELEMENT)
{
continue;
}
CHK_HR(GetAttributeFromNode(pDate, L"acquisition_date", &varValue));
queryDate = QString::fromWCharArray(_bstr_t(varValue));
int intDate = queryDate.toInt();
QDate date = (QDate::fromString("1900-01-01", "yyyy-MM-dd")).addDays(intDate-693962);
QTreeWidgetItem * dateItem = new QTreeWidgetItem(patientItem, QStringList(date.toString("yyyy-MM-dd")));
dateItem->setExpanded(true);
IXMLDOMNodeList * pProtocols = NULL;
CHK_HR(pDate->get_childNodes(&pProtocols));
long nProtocols;
CHK_HR(pProtocols->get_length(&nProtocols));
for (long j=0; j<nProtocols; ++j)
{
IXMLDOMNode * pProtocol = NULL;
CHK_HR(pProtocols->get_item(j, &pProtocol));
CHK_HR(pProtocol->get_nodeType(&nodeType));
if(nodeType!=NODE_ELEMENT)
{
continue;
}
CHK_HR(GetAttributeFromNode(pProtocol, L"protocol_name", &varValue));
queryProtocol = QString::fromWCharArray(_bstr_t(varValue));
QTreeWidgetItem * protocolItem = new QTreeWidgetItem(dateItem, QStringList(queryProtocol));
protocolItem->setExpanded(true);
IXMLDOMNodeList * pCollections = NULL;
CHK_HR(pProtocol->get_childNodes(&pCollections));
long nCollections;
CHK_HR(pCollections->get_length(&nCollections));
for (long j=0; j<nCollections; ++j)
{
IXMLDOMNode * pCollection = NULL;
CHK_HR(pCollections->get_item(j, &pCollection));
CHK_HR(pCollection->get_nodeType(&nodeType));
if(nodeType!=NODE_ELEMENT)
{
continue;
}
CHK_HR(GetAttributeFromNode(pCollection, L"acquisition_number", &varValue));
queryCollection = QString::fromWCharArray(_bstr_t(varValue));
QTreeWidgetItem * collectionItem = new QTreeWidgetItem(protocolItem);
QString queryStr = QString("root/Patient[@patients_name = '%1']/Date[@acquisition_date = '%2']/Protocol[@protocol_name = '%3']/Collection[@acquisition_number = '%4']")
.arg(queryPatient).arg(queryDate).arg(queryProtocol).arg(queryCollection);
IXMLDOMElement * pDtiNode = NULL;
bstrQuery = SysAllocString(QString(queryStr+"/DTI").toStdWString().c_str());
//.........这里部分代码省略.........