Results 1 to 10 of 10

Thread: how to give xml file

  1. #1
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default how to give xml file

    Qt Code:
    1. import QtQuick 2.3
    2. import QtQuick.XmlListModel 2.0
    3. import QtQuick.Controls 1.2
    4. import QtQuick.Window 2.0
    5. import QtQuick.Layouts 1.1
    6. import QtQuick.Controls.Styles 1.2
    7.  
    8. import ydsTest 1.0
    9.  
    10. Window
    11. {
    12. visible: true
    13. width: 360
    14. height: 240
    15.  
    16. Component
    17. {
    18. id: delegate
    19. Label
    20. {
    21. text: BCID
    22. }
    23. }
    24.  
    25. ListView
    26. {
    27. id: view
    28. anchors.fill: parent
    29. model: model
    30. delegate: delegate
    31. }
    32. XmlListModel
    33. {
    34. id: model
    35. source: "Sample621.xml"
    36. query: "/BCINFO/BC"
    37.  
    38. XmlRole
    39. {
    40. name: "BCID";
    41. query: "BCID/string()"
    42. }
    43. }
    44.  
    45. YDSTest
    46. {
    47. id:ydsTest
    48. }
    49. }
    To copy to clipboard, switch view to plain text mode 

    how can i pass XmlListModel file to source.

    Sample621.xml is in application directory
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?><<?xml version="1.0" ?>
    2. <BCINFO>
    3. <BC>
    4. <BCID>621</BCID>
    5. <LABEL>YazmiAud</LABEL>
    6. <BITRATE>32</BITRATE>
    7. <SC_COUNT>1</SC_COUNT>
    8. <SC>
    9. <SC_INDEX>0</SC_INDEX>
    10. <SC_BITRATE>32</SC_BITRATE>
    11. <SC_TYPE>0</SC_TYPE>
    12. <SC_LANGUAGE>0</SC_LANGUAGE>
    13. <SC_PROGRAM_TYPE>0</SC_PROGRAM_TYPE>
    14. </SC>
    15. </BC>
    16. </BCINFO>/>
    To copy to clipboard, switch view to plain text mode 
    add 621
    to xml role can anybody help
    Last edited by anda_skoa; 27th September 2016 at 11:55. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to give xml file

    That looks mostly good to me, but I think the value for XmlRole::name needs to start with a lowercase character.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: how to give xml file

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to give xml file

    Ah.

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

    Cheers,
    _

  5. #5
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: how to give xml file

    yes

    how to remove below line with Qxmlstreamer

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

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to give xml file

    Quote Originally Posted by mouni View Post
    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?

    Quote Originally Posted by mouni View Post
    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,
    _

  7. #7
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: how to give xml file

    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

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to give xml file

    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,
    _

  9. #9
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: how to give xml file

    how to write can u give some example

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to give xml file

    Assuming m_sdatastring is the QByteArray you got from readAll(), then

    Qt Code:
    1. file.write(m_sdatastring);
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. How to give QextSerialPort example a Gui?
    By Jeroenbruinsma in forum Newbie
    Replies: 1
    Last Post: 5th March 2012, 02:40
  2. what should I give url?
    By sups in forum Qt Programming
    Replies: 1
    Last Post: 21st February 2011, 00:22
  3. who can give me a tutorials of write .pro file
    By fengtian.we in forum Qt Programming
    Replies: 5
    Last Post: 20th May 2007, 17:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.