I have a xml template like given below.
<Main_tag>
<SubTag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
</SubTag1>
<SubTag2>
</SubTag2>
<SubTag3>
<SubTag3>
<SubTag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
</Subtag4>
</Main_tag>
<Main_tag>
<SubTag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
</SubTag1>
<SubTag2>
</SubTag2>
<SubTag3>
<SubTag3>
<SubTag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
</Subtag4>
</Main_tag>
To copy to clipboard, switch view to plain text mode
The program should make a copy(template will be read-only) and edit it according to the previous part of program. but basically a final copy should look somthing like.
<Main_tag>
<SubTag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
</SubTag1>
<SubTag2>
<Content_tag2> ... </Content_tag2>
<Content_tag2> ... </Content_tag2>
</SubTag2>
<SubTag3>
<Content_tag3> ... </Content_tag3>
<Content_tag3> ... </Content_tag3>
<Content_tag3> ... </Content_tag3>
</SubTag3>
<SubTag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
</Subtag4>
</Main_tag>
<Main_tag>
<SubTag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
<Content_tag1> ... </Content_tag1>
</SubTag1>
<SubTag2>
<Content_tag2> ... </Content_tag2>
<Content_tag2> ... </Content_tag2>
</SubTag2>
<SubTag3>
<Content_tag3> ... </Content_tag3>
<Content_tag3> ... </Content_tag3>
<Content_tag3> ... </Content_tag3>
</SubTag3>
<SubTag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
<Content_tag4> ... </Content_tag4>
</Subtag4>
</Main_tag>
To copy to clipboard, switch view to plain text mode
the tags and remains exactly the same, and the number of childs in and can vary according to previous part of the program. I am open to either DomDocument or XmlStreamReader. it should also make a attribute tab for every attribute like Content_tag2 or Content_tag3
I have a basic domdocument code, where the program opens the xml file and reads, but i am stuck at the part where the program should make a copy and add in attributes in correct header.
void XMLReader::ReadFromXMLFile()
{
File =new QFile(filename
);
{
qDebug("Error: Cannot read file ");
}
dom.setContent(File);
QDomNode Node
= FirstElement.
firstChild();
while (!Node.isNull())
{
if(!Element.isNull())
{
void XMLReader::ReadFromXMLFile()
{
QString filename="mypath";
File =new QFile(filename);
File->open(QIODevice::ReadOnly);
if (!File->open(QFile::ReadOnly | QFile::Text))
{
qDebug("Error: Cannot read file ");
}
QDomDocument dom;
dom.setContent(File);
QDomElement FirstElement = dom.documentElement();
QDomNode Node = FirstElement.firstChild();
while (!Node.isNull())
{
QDomElement Element = Node.toElement();
if(!Element.isNull())
{
To copy to clipboard, switch view to plain text mode
Any help will be appriciated.
Bookmarks