PDA

View Full Version : how to give xml file



mouni
27th September 2016, 10:24
import QtQuick 2.3
import QtQuick.XmlListModel 2.0
import QtQuick.Controls 1.2
import QtQuick.Window 2.0
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2

import ydsTest 1.0

Window
{
visible: true
width: 360
height: 240

Component
{
id: delegate
Label
{
text: BCID
}
}

ListView
{
id: view
anchors.fill: parent
model: model
delegate: delegate
}
XmlListModel
{
id: model
source: "Sample621.xml"
query: "/BCINFO/BC"

XmlRole
{
name: "BCID";
query: "BCID/string()"
}
}

YDSTest
{
id:ydsTest
}
}


how can i pass XmlListModel file to source.

Sample621.xml is in application directory


<?xml version="1.0" encoding="UTF-8"?><<?xml version="1.0" ?>
<BCINFO>
<BC>
<BCID>621</BCID>
<LABEL>YazmiAud</LABEL>
<BITRATE>32</BITRATE>
<SC_COUNT>1</SC_COUNT>
<SC>
<SC_INDEX>0</SC_INDEX>
<SC_BITRATE>32</SC_BITRATE>
<SC_TYPE>0</SC_TYPE>
<SC_LANGUAGE>0</SC_LANGUAGE>
<SC_PROGRAM_TYPE>0</SC_PROGRAM_TYPE>
</SC>
</BC>
</BCINFO>/>

add 621
to xml role can anybody help

anda_skoa
27th September 2016, 10:58
That looks mostly good to me, but I think the value for XmlRole::name needs to start with a lowercase character.

Cheers,
_

mouni
27th September 2016, 11:05
source: "http://192.168.1.1/bcheader=621"

from this url data is coming ..

i am writing in to flie and giving to source


when i give http ulr then it is adding ....

why it is not adding from xml file...

about this any idea

anda_skoa
27th September 2016, 12:22
Ah.

Is the file in the same directory as the QML file?

Cheers,
_

mouni
27th September 2016, 14:03
yes

how to remove below line with Qxmlstreamer

<?xml version="1.0" encoding="UTF-8"?><<?xml version="1.0" ?>

anda_skoa
27th September 2016, 14:54
yes

So, just to be sure: the QML file is also loaded from disk, not from a resource or something like that?

Do you do the download in C++?
Have you tried returning a QUrl from there instead of a filename?



how to remove below line with Qxmlstreamer

<?xml version="1.0" encoding="UTF-8"?><<?xml version="1.0" ?>
Not sure what QXmlStreamer is, but that doesn't look like valid XML, there is an additional "<" character in there.

If that is in your local file but not in the online file, then how did it end up in the local file?

Cheers,
_

mouni
28th September 2016, 06:36
writing data from online information from net to xml file and given that file ...


qDebug() << m_sdatastring;

QFile file("Sample621.xml");
file.open(QIODevice::WriteOnly);
QXmlStreamWriter xmlWriter(&file);
xmlWriter.writeStartElement(m_sdatastring);
xmlWriter.setAutoFormatting(true);
xmlWriter.writeEndElement();


file.close();

m_sdatastring is socket readall data in qt

anda_skoa
28th September 2016, 10:00
Ah, that is wrong of course.
The data from the socket is a full XML document, not the name of a single tag.

Just write the content into the file.
There is no need to use QXmlStreamWriter as you are not creating XML content.

Cheers,
_

mouni
28th September 2016, 10:51
how to write can u give some example

anda_skoa
28th September 2016, 11:07
Assuming m_sdatastring is the QByteArray you got from readAll(), then



file.write(m_sdatastring);


Cheers,
_