<?xml version="1.0" encoding="utf-8"?> <NetDataEvaluateSet> <AnalysisNet name="柯桥供水(kqgs)" desc="柯桥供水"></AnalysisNet> <Analysis isAnalysis="true" desc="重叠管点分析" name="RepeatPointAnalysis"> <Analysis value="0.5"/> </Analysis> <Analysis isAnalysis="true" desc="重叠管线分析" name="RepeatLineAnalysis"> <Analysis value="0.001"/> </Analysis> <Analysis isAnalysis="true" desc="相交管线分析" name="IntersectLineAnalysis"> <Analysis flag="false"/> </Analysis> <Analysis isAnalysis="true" desc="超短线分析" name="ShortLineAnalysis"> <Analysis value="0.002"/> </Analysis> <Analysis isAnalysis="true" desc="近线点分析" name="NearLineNodeAnalysis"> <Analysis value="0.05"/> </Analysis> <Analysis isAnalysis="true" desc="孤立管线分析" name="IsolatedLineAnalysis"> <Analysis value="1"/> </Analysis> <Analysis isAnalysis="true" desc="飞点范围" name="NetConnectivityAnalysis"> <Analysis flag="false"/> </Analysis> <Analysis isAnalysis="true" desc="管网连通性分析" name="NetConnectivityAnalysis"> <Analysis flag="false"/> </Analysis> <Analysis isAnalysis="true" desc="连接度分析" name="LinkDegreeAnalysis"> <Analysis items="三通连接度"/> </Analysis> <Analysis isAnalysis="true" desc="连接规则分析" name="LinkRuleAnalysis"> <Analysis items="变径分析"/> </Analysis> </NetDataEvaluateSet>生成qt写xml代码
时间: 2023-07-06 08:41:07 浏览: 78
动态网页程序设计代码等 <?xml version="1.0" encoding="utf-8" ?>
我可以为您提供一个生成 Qt 写 XML 代码的示例,供您参考:
```cpp
#include <QXmlStreamWriter>
#include <QFile>
void writeXmlFile(const QString& fileName) {
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
// 处理文件打开失败的情况
return;
}
QXmlStreamWriter writer(&file);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement("NetDataEvaluateSet");
// 写入 AnalysisNet 元素
writer.writeStartElement("AnalysisNet");
writer.writeAttribute("name", "柯桥供水(kqgs)");
writer.writeAttribute("desc", "柯桥供水");
writer.writeEndElement();
// 写入 RepeatPointAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "重叠管点分析");
writer.writeAttribute("name", "RepeatPointAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("value", "0.5");
writer.writeEndElement();
writer.writeEndElement();
// 写入 RepeatLineAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "重叠管线分析");
writer.writeAttribute("name", "RepeatLineAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("value", "0.001");
writer.writeEndElement();
writer.writeEndElement();
// 写入 IntersectLineAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "相交管线分析");
writer.writeAttribute("name", "IntersectLineAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("flag", "false");
writer.writeEndElement();
writer.writeEndElement();
// 写入 ShortLineAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "超短线分析");
writer.writeAttribute("name", "ShortLineAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("value", "0.002");
writer.writeEndElement();
writer.writeEndElement();
// 写入 NearLineNodeAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "近线点分析");
writer.writeAttribute("name", "NearLineNodeAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("value", "0.05");
writer.writeEndElement();
writer.writeEndElement();
// 写入 IsolatedLineAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "孤立管线分析");
writer.writeAttribute("name", "IsolatedLineAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("value", "1");
writer.writeEndElement();
writer.writeEndElement();
// 写入 NetConnectivityAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "飞点范围");
writer.writeAttribute("name", "NetConnectivityAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("flag", "false");
writer.writeEndElement();
writer.writeEndElement();
// 写入 NetConnectivityAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "管网连通性分析");
writer.writeAttribute("name", "NetConnectivityAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("flag", "false");
writer.writeEndElement();
writer.writeEndElement();
// 写入 LinkDegreeAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "连接度分析");
writer.writeAttribute("name", "LinkDegreeAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("items", "三通连接度");
writer.writeEndElement();
writer.writeEndElement();
// 写入 LinkRuleAnalysis 元素
writer.writeStartElement("Analysis");
writer.writeAttribute("isAnalysis", "true");
writer.writeAttribute("desc", "连接规则分析");
writer.writeAttribute("name", "LinkRuleAnalysis");
writer.writeStartElement("Analysis");
writer.writeAttribute("items", "变径分析");
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndDocument();
file.close();
}
```
您可以根据您的需求修改该示例代码,来生成符合您要求的 XML 文件。
阅读全文