I have this xml file, for a storyboard program.
First I retrieve the general info about the storyboard, such as number of pads, size etc.
Then I retrieve the storyboard folder. Here I keep pixmaps in the folder 'sc1', but they are created at runtime, and not saved.
Number of pads in this example are 4. Each pad starts with an entry with timing and count, and inside this tag, you'll find points and pen color for drawing lines on a QGraphicsScene.
<?xml version="1.0" encoding="UTF-8"?>
<project>
<info project_name="matt2" project_path="C:/Users/david/matt2" pad_count="4" pad_width="800" pad_height="600"/>
<storyboard folder="sc1">
<0 timing="50" count="36">
<0 p1x="285" p1y="79" p2x="286" p2y="79" rgb="4293958640"/>
...
<35 p1x="326" p1y="175" p2x="326" p2y="175" rgb="4293958640"/>
</0>
<1 timing="75" count="30">
<0 p1x="319" p1y="95" p2x="320" p2y="95" rgb="4293958640"/>
...
<29 p1x="292" p1y="113" p2x="292" p2y="113" rgb="4287102865"/>
</1>
<2 timing="50" count="26">
<0 p1x="170" p1y="53" p2x="175" p2y="53" rgb="4287102865"/>
...
<25 p1x="299" p1y="65" p2x="299" p2y="65" rgb="4291326770"/>
</2>
<3 timing="50" count="12">
<0 p1x="298" p1y="43" p2x="298" p2y="44" rgb="4291326770"/>
...
<11 p1x="269" p1y="73" p2x="269" p2y="73" rgb="4291326770"/>
</3>
</storyboard>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project>
<info project_name="matt2" project_path="C:/Users/david/matt2" pad_count="4" pad_width="800" pad_height="600"/>
<storyboard folder="sc1">
<0 timing="50" count="36">
<0 p1x="285" p1y="79" p2x="286" p2y="79" rgb="4293958640"/>
...
<35 p1x="326" p1y="175" p2x="326" p2y="175" rgb="4293958640"/>
</0>
<1 timing="75" count="30">
<0 p1x="319" p1y="95" p2x="320" p2y="95" rgb="4293958640"/>
...
<29 p1x="292" p1y="113" p2x="292" p2y="113" rgb="4287102865"/>
</1>
<2 timing="50" count="26">
<0 p1x="170" p1y="53" p2x="175" p2y="53" rgb="4287102865"/>
...
<25 p1x="299" p1y="65" p2x="299" p2y="65" rgb="4291326770"/>
</2>
<3 timing="50" count="12">
<0 p1x="298" p1y="43" p2x="298" p2y="44" rgb="4291326770"/>
...
<11 p1x="269" p1y="73" p2x="269" p2y="73" rgb="4291326770"/>
</3>
</storyboard>
</project>
To copy to clipboard, switch view to plain text mode
After opening the file I have this code, that works
doc.setContent(&file);
file.close();
if (n.nodeName() == "info")
{
QDomDocument doc;
doc.setContent(&file);
file.close();
QDomElement root = doc.documentElement();
QDomNode n = root.firstChild();
if (n.nodeName() == "info")
{
QDomElement e = n.toElement();
To copy to clipboard, switch view to plain text mode
Here comes the part where it goes wrong.
I can get the folder of the storyboard, but when I write: "QDomNode pad = n.firstChild();", pad is NULL. I can't get to the actual pad information.
// now load Storyboards...
n = n.nextSibling();
while (!n.isNull())
{
if (n.nodeName() == "storyboard")
{
mActiveStoryboard = s1.attribute("folder", "");
qDebug() << "storyboard: " << mActiveStoryboard;
while (!pad.isNull())
{
qDebug() << "pad: " << pad.nodeName();
pad = pad.nextSibling();
// now load Storyboards...
n = n.nextSibling();
while (!n.isNull())
{
QDomElement s1 = n.toElement();
if (n.nodeName() == "storyboard")
{
mActiveStoryboard = s1.attribute("folder", "");
qDebug() << "storyboard: " << mActiveStoryboard;
QDomNode pad = n.firstChild();
while (!pad.isNull())
{
QDomElement s2 = pad.toElement();
qDebug() << "pad: " << pad.nodeName();
pad = pad.nextSibling();
To copy to clipboard, switch view to plain text mode
Can anyone please help me retrive "<0 timing="50" count="36">"?
I feel I have tried everything, and it must be n.firstChild(), or...? Please enlighten me
Bookmarks