Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在Qt4.8中的XML文件中的同一元素中添加多个属性_C++_Xml_Qt - Fatal编程技术网

C++ 如何在Qt4.8中的XML文件中的同一元素中添加多个属性

C++ 如何在Qt4.8中的XML文件中的同一元素中添加多个属性,c++,xml,qt,C++,Xml,Qt,我正在使用qt4.8在我的XML文件中添加多个属性。它将是这样的:- <Communication xmlns="http://tempuri.org/communication.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <Communication xmlns:xs="http://tempuri.org/communication.xsd"> 现在我尝试添加我的属性:- xw.writeAttribute(

我正在使用
qt4.8
在我的XML文件中添加多个属性。它将是这样的:-

<Communication xmlns="http://tempuri.org/communication.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Communication xmlns:xs="http://tempuri.org/communication.xsd">
现在我尝试添加我的属性:-

xw.writeAttribute("xmlns=","http://tempuri.org/communication.xsd");
xw.writeAttribute("xmlns:xs=","http://www.w3.org/2001/XMLSchema");
但不幸的是,
writeAttribute
函数只能在创建元素之后才能工作。请告诉我这件事。因此,我的输出如下:-

<Communication xmlns="http://tempuri.org/communication.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Communication xmlns:xs="http://tempuri.org/communication.xsd">


所以,我想知道如何在同一个元素中添加多个属性。请帮忙。谢谢。

那怎么办?这就是我正在使用的bro,但不能对同一个元素使用两次。请阅读我提到的doct,它表示
QXmlStreamAttribute
的向量。我不知道如何使用它,不是doc。帮忙?我没有经验,只是出于好奇用谷歌搜索。医生。说明:可以使用
append()
添加新属性。听起来很容易。。。