当前位置: 首页>>代码示例>>C++>>正文


C++ QDomDocument::removeChild方法代码示例

本文整理汇总了C++中QDomDocument::removeChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::removeChild方法的具体用法?C++ QDomDocument::removeChild怎么用?C++ QDomDocument::removeChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDomDocument的用法示例。


在下文中一共展示了QDomDocument::removeChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: removeChild

QDomNode QDomDocumentProto::removeChild(const QDomNode& oldChild)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->removeChild(oldChild);
    return QDomNode();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: sendGetFeature

void QgsWFSServer::sendGetFeature( QgsRequestHandler& request, const QString& format, QgsFeature* feat, int featIdx, QgsCoordinateReferenceSystem& crs, QMap< int, QgsField > fields, QSet<QString> hiddenAttributes ) /*const*/
{
  QByteArray result;
  if ( format == "GeoJSON" )
  {
    QString fcString;
    if ( featIdx == 0 )
      fcString += "  ";
    else
      fcString += " ,";
    fcString += createFeatureGeoJSON( feat, crs, fields, hiddenAttributes );
    fcString += "\n";

    result = fcString.toUtf8();
    request.sendGetFeatureResponse( &result );
    fcString = "";
  }
  else
  {
    QDomDocument gmlDoc;
    QDomElement featureElement = createFeatureElem( feat, gmlDoc, crs, fields, hiddenAttributes );
    gmlDoc.appendChild( featureElement );

    result = gmlDoc.toByteArray();
    request.sendGetFeatureResponse( &result );
    gmlDoc.removeChild( featureElement );
  }
}
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:28,代码来源:qgswfsserver.cpp

示例3: testGeometryToGML

void TestQgsOgcUtils::testGeometryToGML()
{
  QDomDocument doc;
  QgsGeometry* geomPoint = QgsGeometry::fromPoint( QgsPoint( 111, 222 ) );
  QgsGeometry* geomLine = QgsGeometry::fromWkt( "LINESTRING(111 222, 222 222)" );

  // Test GML2
  QDomElement elemInvalid = QgsOgcUtils::geometryToGML( 0, doc );
  QVERIFY( elemInvalid.isNull() );

  QDomElement elemPoint = QgsOgcUtils::geometryToGML( geomPoint, doc );
  QVERIFY( !elemPoint.isNull() );

  doc.appendChild( elemPoint );
  QCOMPARE( doc.toString( -1 ), QString( "<gml:Point><gml:coordinates cs=\",\" ts=\" \">111,222</gml:coordinates></gml:Point>" ) );
  doc.removeChild( elemPoint );

  QDomElement elemLine = QgsOgcUtils::geometryToGML( geomLine, doc );
  QVERIFY( !elemLine.isNull() );

  doc.appendChild( elemLine );
  QCOMPARE( doc.toString( -1 ), QString( "<gml:LineString><gml:coordinates cs=\",\" ts=\" \">111,222 222,222</gml:coordinates></gml:LineString>" ) );
  doc.removeChild( elemLine );

  // Test GML3
  elemInvalid = QgsOgcUtils::geometryToGML( 0, doc, "GML3" );
  QVERIFY( elemInvalid.isNull() );

  elemPoint = QgsOgcUtils::geometryToGML( geomPoint, doc, "GML3" );
  QVERIFY( !elemPoint.isNull() );

  doc.appendChild( elemPoint );
  QCOMPARE( doc.toString( -1 ), QString( "<gml:Point><gml:pos srsDimension=\"2\">111 222</gml:pos></gml:Point>" ) );
  doc.removeChild( elemPoint );

  elemLine = QgsOgcUtils::geometryToGML( geomLine, doc, "GML3" );
  QVERIFY( !elemLine.isNull() );

  doc.appendChild( elemLine );
  QCOMPARE( doc.toString( -1 ), QString( "<gml:LineString><gml:posList srsDimension=\"2\">111 222 222 222</gml:posList></gml:LineString>" ) );
  doc.removeChild( elemLine );

  delete geomPoint;
  delete geomLine;
}
开发者ID:AaronGaim,项目名称:QGIS,代码行数:45,代码来源:testqgsogcutils.cpp

示例4: verify

TestResult::Status TestBaseLine::verify(const QString &serializedInput) const
{
    switch(m_type)
    {
        case SchemaIsValid:
        /* Fall through. */
        case Text:
        {
            if(serializedInput == details())
                return TestResult::Pass;
            else
                return TestResult::Fail;
        }
        case Fragment:
        /* Fall through. */
        case XML:
        {
            /* Read the baseline and the serialized input into two QDomDocuments, and compare
             * them deeply. We wrap fragments in a root node such that it is well-formed XML.
             */

            QDomDocument output;
            {
                /* The reason we put things into a QByteArray and then parse it through QXmlSimpleReader, is that
                 * QDomDocument does whitespace stripping when calling setContent(QString). In other words,
                 * this workarounds a bug. */

                QXmlInputSource source;
                source.setData((m_type == XML ? serializedInput : QLatin1String("<r>") +
                                                                  serializedInput +
                                                                  QLatin1String("</r>")).toUtf8());

                QString outputReadingError;

                QXmlSimpleReader reader;
                reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true);

                const bool success = output.setContent(&source,
                                                       &reader,
                                                       &outputReadingError);

                if(!success)
                    return TestResult::Fail;

                Q_ASSERT(success);
            }

            QDomDocument baseline;
            {
                QXmlInputSource source;
                source.setData((m_type == XML ? details() : QLatin1String("<r>") +
                                                            details() +
                                                            QLatin1String("</r>")).toUtf8());
                QString baselineReadingError;

                QXmlSimpleReader reader;
                reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true);

                const bool success = baseline.setContent(&source,
                                                         &reader,
                                                         &baselineReadingError);

                if(!success)
                    return TestResult::Fail;

                /* This piece of code workaround a bug in QDom, which treats XML prologs as processing
                 * instructions and make them available in the tree as so. */
                if(m_type == XML)
                {
                    /* $doc/r/node() */
                    const QDomNodeList children(baseline.childNodes());
                    const int len = children.length();

                    for(int i = 0; i < len; ++i)
                    {
                        const QDomNode &child = children.at(i);
                        if(child.isProcessingInstruction() && child.nodeName() == QLatin1String("xml"))
                        {
                            baseline.removeChild(child);
                            break;
                        }
                    }
                }

                Q_ASSERT_X(baselineReadingError.isNull(), Q_FUNC_INFO,
                           qPrintable((QLatin1String("Reading the baseline failed: ") + baselineReadingError)));
            }

            if(isDeepEqual(output, baseline))
                return TestResult::Pass;
            else
            {
                pDebug() << "FAILURE:" << output.toString() << "is NOT IDENTICAL to(baseline):" << baseline.toString();
                return TestResult::Fail;
            }
        }
        case Ignore:
            return TestResult::Pass;
        case Inspect:
            return TestResult::NotTested;
//.........这里部分代码省略.........
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:101,代码来源:TestBaseLine.cpp


注:本文中的QDomDocument::removeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。