Need enlightenment with XmlListModel

  • Hello everyone,

    I hope this is the right place to ask for help in the following matter, if not just point me in the right direction.
    I'm trying to use XmlListModel with a xml file I got from a server. I think the problem may be with namespace declarations but I have tried many combinations without success. To be sure I could use this qml type, I tried this with another xml file - - all went good!

    Here's a portion of the "problematic" xml file:

    <?xml version="1.0"?>
    <s:Envelope xmlns:s="" xmlns:u="">
    		<o:Security xmlns:o="" s:mustUnderstand="1">
    			<u:Timestamp u:Id="_0">
    	<s:Body xmlns:xsi="" xmlns:xsd="">
    		<RecebeResponse xmlns="">
    				<Pedido xmlns="" id="1" data="2018-02-07" hora="20:03">
    						<Actualizacao id="8479" data="2018-02-05" hora="00:36">
    									<Posto id="67270">
    										<Nome> BP Xabregas</Nome>
    										<Localidade>Lisboa - Xabregas</Localidade>
    										<Morada>Av. Infante D.Henrique, 61</Morada>
    										<HorarioDiasUteis>Hor&#xE1;rio espec&#xED;fico</HorarioDiasUteis>
    										<HorarioSabados>Hor&#xE1;rio espec&#xED;fico</HorarioSabados>
    										<HorarioDomFeriados>Hor&#xE1;rio espec&#xED;fico</HorarioDomFeriados>
    										<Observacoes>Pagamentos com cart&#xE3;o Routex&#xD;
    Desconto aos portadores de cart&#xE3;o Azul BP&#xD;
    Desconto aos portadores de cart&#xE3;o ACP&#xD;
    Desconto aos portadores de cart&#xE3;o INATEL&#xD;
    Desconto aos portadores de cart&#xE3;o Poupa Mais&#xD;
    Desconto aos portadores de cart&#xF5;es BP/Acordos</Observacoes>
    											<Servico>Venda de carburante de qualidade superior</Servico>
    											<Servico>Venda de g&#xE1;s dom&#xE9;stico em garrafas</Servico>
    											<Servico>Calibragem de pneus</Servico>
    											<Servico>Loja de Conveni&#xEA;ncia</Servico>

    Here's my qml code:

    import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtQuick.XmlListModel 2.0
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        XmlListModel {
            id: xmlModel
    		source: "qrc:/xml/dataFULL.xml"
            query: "/Envelope/Body/RecebeResponse/RecebeResult/Pedido/Actualizacoes/Actualizacao/Postos/Existentes/Posto"
            namespaceDeclarations: "declare default element namespace '';"+
                                   "declare namespace u='';"+
                                   "declare namespace o='';"+
                                   "declare namespace xsi='';"+
                                   "declare namespace xsd='';"
            XmlRole { name: "Nome"; query: "Nome/string()"}
            id: list
            width: 300; height: 300
            model: xmlModel
            delegate: Text { text: Nome }

    With this code the "Text" in the ListView doesn't show anything.
    I'm think this model have some error but I don't know how to retrieve the error to fix it.

    Hope someone can give me a hand figuring this out!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.