IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Discussion :

Probleme erreur xml

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 8
    Par défaut Probleme erreur xml
    Bonjours j ai une erreur XML ERROR: 494 : "XML declaration not at start of document."
    lorsque je change d index dans ma combobox.

    Voici le code.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    connect(ligueComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(combobox(int)));
     
    void RSSListing::combobox(int selection)
    {
        switch (selection) {
        case 1:
            connect(fetchButton, SIGNAL(clicked()),this,SLOT(ligue1()));
            break;
        case 2:
            connect(fetchButton, SIGNAL(clicked()),this,SLOT(ligue2()));
            break;
     
        case 3:
            connect(fetchButton, SIGNAL(clicked()),this,SLOT(autres()));
            break;
     
    }
     
     
    Si j écrit le code suivant cela fonctionne:
     
    void RSSListing::combobox(int selection)
    {
        switch (selection) {
        case 1:
    ligue1()
    break;
    case 2:
    ligue2()
    break;
    case 3:
    autres()
    break;
    Je voudrais lancer les slots ligue1,ligue2 et autres par appuis sur le fetchButton.
    Auriez vous une solution a me proposer,merci d avance.

  2. #2
    Responsable Qt & Livres


    Avatar de dourouc05
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2008
    Messages
    26 754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2008
    Messages : 26 754
    Par défaut


    Il me semble que, vu l'erreur, le fichier XML est aussi à blâmer... Pourrais-tu nous donner un exemple de ficheir qui renvoie l'erreur ?
    Vous souhaitez participer aux rubriques Qt (tutoriels, FAQ, traductions) ou HPC ? Contactez-moi par MP.

    Créer des applications graphiques en Python avec PyQt5
    Créer des applications avec Qt 5.

    Pas de question d'ordre technique par MP !

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 8
    Par défaut
    Merci de ta réponse voici le code.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    #
    void RSSListing::finished(int id, bool error)
    {
        if (error) {
            qWarning("Received error during HTTP fetch.");
            abortButton->setEnabled(false);
            fetchButton->setEnabled(true);
        }
        else if (id == connectionId) {
            abortButton->setEnabled(false);
            fetchButton->setEnabled(true);
        }
    }
     
     
    /*
        Parses the XML data and creates treeWidget items accordingly.
    */
    void RSSListing::parseXml()
    {
        while (!xml.atEnd()) {
            xml.readNext();
            if (xml.isStartElement()) {
                if (xml.name() == "item")
                    linkString = xml.attributes().value("rss:about").toString();
                currentTag = xml.name().toString();
            } else if (xml.isEndElement()) {
                if (xml.name() == "item") {
     
                    QTreeWidgetItem *item = new QTreeWidgetItem;
                    item->setText(0, titleString);
                    item->setText(1, linkString);
                    treeWidget->addTopLevelItem(item);
     
                    titleString.clear();
                    linkString.clear();
                }
     
            } else if (xml.isCharacters() && !xml.isWhitespace()) {
                if (currentTag == "title")
                    titleString += xml.text().toString();
                else if (currentTag == "link")
                    linkString += xml.text().toString();
            }
        }
        if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
            qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString();
            http.abort();
        }
    }
     
    /*
        Open the link in the browser
    */
    void RSSListing::itemActivated(QTreeWidgetItem * item)
    {
        QDesktopServices::openUrl(QUrl(item->text(1)));
    }

  4. #4
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 074
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 074
    Billets dans le blog
    144
    Par défaut
    Citation Envoyé par dourouc05 Voir le message


    Il me semble que, vu l'erreur, le fichier XML est aussi à blâmer... Pourrais-tu nous donner un exemple de ficheir qui renvoie l'erreur ?
    Bonjour,

    Ce qui est demandé ici, est le fichier XML que vous essayez de lire et qui provoque l'erreur.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 8
    Par défaut
    voici le code complet:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    #include <QtCore>
    #include <QtGui>
    #include <QtNetwork>
     
    #include "foot.h"
     
    RSSListing::RSSListing(QWidget *parent)
        : QWidget(parent)
    {
        fetchButton = new QPushButton(tr("Go"), this);
        abortButton = new QPushButton(tr("Annuler"), this);
        abortButton->setEnabled(false);
     
        QStringList foot;
             foot << "ligue1" << "ligue2" << "autres" ;
     
        ligueComboBox = new QComboBox;
        ligueComboBox->addItem( tr( "choisir" ));
        ligueComboBox->addItem( tr( "ligue1" ));
        ligueComboBox->addItem(tr("ligue2"));
        ligueComboBox->addItem(tr("autres"));
     
     
     
     
     
        treeWidget = new QTreeWidget(this);
        connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
                this, SLOT(itemActivated(QTreeWidgetItem*)));
     
     
     
        QStringList headerLabels;
        headerLabels << tr("Info") ;
        treeWidget->setHeaderLabels(headerLabels);
        treeWidget->header()->setResizeMode(QHeaderView::ResizeToContents);
     
        connect(&http, SIGNAL(readyRead(QHttpResponseHeader)),
                 this, SLOT(readData(QHttpResponseHeader)));
     
        connect(&http, SIGNAL(requestFinished(int,bool)),
                 this, SLOT(finished(int,bool)));
     
     
        connect(ligueComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(combobox(int)));
     
     
     
     
        connect(abortButton, SIGNAL(clicked()), &http, SLOT(abort()));
     
        QVBoxLayout *layout = new QVBoxLayout(this);
     
        QHBoxLayout *hboxLayout = new QHBoxLayout;
     
        hboxLayout->addWidget(ligueComboBox);
        hboxLayout->addWidget(fetchButton);
        hboxLayout->addWidget(abortButton);
     
        layout->addLayout(hboxLayout);
        layout->addWidget(treeWidget);
     
        setWindowTitle(tr("InfoFoot"));
        resize(800,400);
    }
     
    void RSSListing::ligue1()
    {
     
           fetchButton->setEnabled(false);
        abortButton->setEnabled(true);
        treeWidget->clear();
     
        xml.clear();
     
        QUrl url("http://www.eurosport.fr/football/ligue-1/2009-2010/rss-flash.xml");
     
        http.setHost(url.host());
        connectionId = http.get(url.path());
    }
    void RSSListing::combobox(int selection)
    {
        switch (selection){
        case 1:
           connect(fetchButton, SIGNAL(clicked()), this, SLOT(ligue1()));
            break;
        case 2:
           connect(fetchButton, SIGNAL(clicked()), this, SLOT(ligue2()));
            break;
        case 3:
            connect(fetchButton, SIGNAL(clicked()), this, SLOT(autres()));
            break;
        }
    }
     
    void RSSListing::ligue2()
    {
          fetchButton->setEnabled(false);
        abortButton->setEnabled(true);
        treeWidget->clear();
     
        xml.clear();
     
        QUrl url("http://www.eurosport.fr/football/ligue-2/2009-2010/rss-flash.xml");
     
        http.setHost(url.host());
        connectionId = http.get(url.path());
    }
    void RSSListing::autres()
    {
           fetchButton->setEnabled(false);
        abortButton->setEnabled(true);
        treeWidget->clear();
     
        xml.clear();
     
        QUrl url("http://www.eurosport.fr/football/ligue-2/2009-2010/rss-flash.xml");
     
        http.setHost(url.host());
        connectionId = http.get(url.path());
    }
    void RSSListing::readData(const QHttpResponseHeader &resp)
    {
        if (resp.statusCode() != 200)
            http.abort();
        else {
            xml.addData(http.readAll());
            parseXml();
        }
    }
     
    void RSSListing::finished(int id, bool error)
    {
        if (error) {
            qWarning("Received error during HTTP fetch.");
            abortButton->setEnabled(false);
            fetchButton->setEnabled(true);
        }
        else if (id == connectionId) {
            abortButton->setEnabled(false);
            fetchButton->setEnabled(true);
        }
    }
     
     
    /*
        Parses the XML data and creates treeWidget items accordingly.
    */
    void RSSListing::parseXml()
    {
        while (!xml.atEnd()) {
            xml.readNext();
            if (xml.isStartElement()) {
                if (xml.name() == "item")
                    linkString = xml.attributes().value("rss:about").toString();
                currentTag = xml.name().toString();
            } else if (xml.isEndElement()) {
                if (xml.name() == "item") {
     
                    QTreeWidgetItem *item = new QTreeWidgetItem;
                    item->setText(0, titleString);
                    item->setText(1, linkString);
                    treeWidget->addTopLevelItem(item);
     
                    titleString.clear();
                    linkString.clear();
                }
     
            } else if (xml.isCharacters() && !xml.isWhitespace()) {
                if (currentTag == "title")
                    titleString += xml.text().toString();
                else if (currentTag == "link")
                    linkString += xml.text().toString();
            }
        }
        if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
            qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString();
            http.abort();
        }
    }
     
    /*
        Open the link in the browser
    */
    void RSSListing::itemActivated(QTreeWidgetItem * item)
    {
        QDesktopServices::openUrl(QUrl(item->text(1)));
    }

  6. #6
    Membre expérimenté
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    188
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 188
    Par défaut
    Citation Envoyé par LittleWhite Voir le message
    Bonjour,

    Ce qui est demandé ici, est le fichier XML que vous essayez de lire et qui provoque l'erreur.
    Peut être que la troisième sera la bonne .
    Il faudrait fournir le fichier XML lu ou écrit.

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 8
    Par défaut
    J'espère que je vais en fin vous montrer le bon fichier.Désolé je suis vraiment debutant.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    #ifndef QXMLSTREAM_H
    #define QXMLSTREAM_H
     
    #include <QtCore/qiodevice.h>
     
    #ifndef QT_NO_XMLSTREAM
     
    #include <QtCore/qstring.h>
    #include <QtCore/qvector.h>
    #include <QtCore/qscopedpointer.h>
     
    QT_BEGIN_HEADER
     
    QT_BEGIN_NAMESPACE
     
    QT_MODULE(Core)
     
    #if defined(Q_OS_MAC32) || defined(Q_OS_AIX)
    # if !defined QT_BUILD_XML_LIB
    #  define Q_XMLSTREAM_RENAME_SYMBOLS
    # endif
    #endif
     
    #if defined QT_BUILD_XML_LIB
    # define Q_XMLSTREAM_EXPORT     Q_XML_EXPORT
    #else
    # define Q_XMLSTREAM_EXPORT     Q_CORE_EXPORT
    #endif
     
    #if defined Q_XMLSTREAM_RENAME_SYMBOLS
    // don't worry, we'll undef and change to typedef at the bottom of the file
    # define QXmlStreamAttribute QCoreXmlStreamAttribute
    # define QXmlStreamAttributes QCoreXmlStreamAttributes
    # define QXmlStreamEntityDeclaration QCoreXmlStreamEntityDeclaration
    # define QXmlStreamEntityDeclarations QCoreXmlStreamEntityDeclarations
    # define QXmlStreamEntityResolver QCoreXmlStreamEntityResolver
    # define QXmlStreamNamespaceDeclaration QCoreXmlStreamNamespaceDeclaration
    # define QXmlStreamNamespaceDeclarations QCoreXmlStreamNamespaceDeclarations
    # define QXmlStreamNotationDeclaration QCoreXmlStreamNotationDeclaration
    # define QXmlStreamNotationDeclarations QCoreXmlStreamNotationDeclarations
    # define QXmlStreamReader QCoreXmlStreamReader
    # define QXmlStreamStringRef QCoreXmlStreamStringRef
    # define QXmlStreamWriter QCoreXmlStreamWriter
    #endif
     
    class Q_XMLSTREAM_EXPORT QXmlStreamStringRef {
        QString m_string;
        int m_position, m_size;
    public:
        inline QXmlStreamStringRef():m_position(0), m_size(0){}
        inline QXmlStreamStringRef(const QStringRef &aString)
            :m_string(aString.string()?*aString.string():QString()), m_position(aString.position()), m_size(aString.size()){}
        inline QXmlStreamStringRef(const QString &aString):m_string(aString), m_position(0), m_size(aString.size()){}
        inline ~QXmlStreamStringRef(){}
        inline void clear() { m_string.clear(); m_position = m_size = 0; }
        inline operator QStringRef() const { return QStringRef(&m_string, m_position, m_size); }
        inline const QString *string() const { return &m_string; }
        inline int position() const { return m_position; }
        inline int size() const { return m_size; }
    };
     
     
    class QXmlStreamReaderPrivate;
    class QXmlStreamAttributes;
    class Q_XMLSTREAM_EXPORT QXmlStreamAttribute {
        QXmlStreamStringRef m_name, m_namespaceUri, m_qualifiedName, m_value;
        void *reserved;
        uint m_isDefault : 1;
        friend class QXmlStreamReaderPrivate;
        friend class QXmlStreamAttributes;
    public:
        QXmlStreamAttribute();
        QXmlStreamAttribute(const QString &qualifiedName, const QString &value);
        QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value);
        QXmlStreamAttribute(const QXmlStreamAttribute &);
        QXmlStreamAttribute& operator=(const QXmlStreamAttribute &);
        ~QXmlStreamAttribute();
        inline QStringRef namespaceUri() const { return m_namespaceUri; }
        inline QStringRef name() const { return m_name; }
        inline QStringRef qualifiedName() const { return m_qualifiedName; }
        inline QStringRef prefix() const {
            return QStringRef(m_qualifiedName.string(),
                              m_qualifiedName.position(),
                              qMax(0, m_qualifiedName.size() - m_name.size() - 1));
        }
        inline QStringRef value() const { return m_value; }
        inline bool isDefault() const { return m_isDefault; }
        inline bool operator==(const QXmlStreamAttribute &other) const {
            return (value() == other.value()
                    && (namespaceUri().isNull() ? (qualifiedName() == other.qualifiedName())
                        : (namespaceUri() == other.namespaceUri() && name() == other.name())));
        }
        inline bool operator!=(const QXmlStreamAttribute &other) const
            { return !operator==(other); }
    };
     
    Q_DECLARE_TYPEINFO(QXmlStreamAttribute, Q_MOVABLE_TYPE);
     
    class Q_XMLSTREAM_EXPORT QXmlStreamAttributes : public QVector<QXmlStreamAttribute>
    {
    public:
        QStringRef value(const QString &namespaceUri, const QString &name) const;
        QStringRef value(const QString &namespaceUri, const QLatin1String &name) const;
        QStringRef value(const QLatin1String &namespaceUri, const QLatin1String &name) const;
        QStringRef value(const QString &qualifiedName) const;
        QStringRef value(const QLatin1String &qualifiedName) const;
        void append(const QString &namespaceUri, const QString &name, const QString &value);
        void append(const QString &qualifiedName, const QString &value);
     
        inline bool hasAttribute(const QString &qualifiedName) const
        {
            return !value(qualifiedName).isNull();
        }
     
        inline bool hasAttribute(const QLatin1String &qualifiedName) const
        {
            return !value(qualifiedName).isNull();
        }
     
        inline bool hasAttribute(const QString &namespaceUri, const QString &name) const
        {
            return !value(namespaceUri, name).isNull();
        }
     
    #if !defined(Q_NO_USING_KEYWORD)
        using QVector<QXmlStreamAttribute>::append;
    #else
        inline void append(const QXmlStreamAttribute &attribute)
            { QVector<QXmlStreamAttribute>::append(attribute); }
    #endif
    };
     
    class Q_XMLSTREAM_EXPORT QXmlStreamNamespaceDeclaration {
        QXmlStreamStringRef m_prefix, m_namespaceUri;
        void *reserved;
     
        friend class QXmlStreamReaderPrivate;
    public:
        QXmlStreamNamespaceDeclaration();
        QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &);
        QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri);
        ~QXmlStreamNamespaceDeclaration();
        QXmlStreamNamespaceDeclaration& operator=(const QXmlStreamNamespaceDeclaration &);
        inline QStringRef prefix() const { return m_prefix; }
        inline QStringRef namespaceUri() const { return m_namespaceUri; }
        inline bool operator==(const QXmlStreamNamespaceDeclaration &other) const {
            return (prefix() == other.prefix() && namespaceUri() == other.namespaceUri());
        }
        inline bool operator!=(const QXmlStreamNamespaceDeclaration &other) const
            { return !operator==(other); }
    };
     
    Q_DECLARE_TYPEINFO(QXmlStreamNamespaceDeclaration, Q_MOVABLE_TYPE);
    typedef QVector<QXmlStreamNamespaceDeclaration> QXmlStreamNamespaceDeclarations;
     
    class Q_XMLSTREAM_EXPORT QXmlStreamNotationDeclaration {
        QXmlStreamStringRef m_name, m_systemId, m_publicId;
        void *reserved;
     
        friend class QXmlStreamReaderPrivate;
    public:
        QXmlStreamNotationDeclaration();
        ~QXmlStreamNotationDeclaration();
        QXmlStreamNotationDeclaration(const QXmlStreamNotationDeclaration &);
        QXmlStreamNotationDeclaration& operator=(const QXmlStreamNotationDeclaration &);
        inline QStringRef name() const { return m_name; }
        inline QStringRef systemId() const { return m_systemId; }
        inline QStringRef publicId() const { return m_publicId; }
        inline bool operator==(const QXmlStreamNotationDeclaration &other) const {
            return (name() == other.name() && systemId() == other.systemId()
                    && publicId() == other.publicId());
        }
        inline bool operator!=(const QXmlStreamNotationDeclaration &other) const
            { return !operator==(other); }
    };
     
    Q_DECLARE_TYPEINFO(QXmlStreamNotationDeclaration, Q_MOVABLE_TYPE);
    typedef QVector<QXmlStreamNotationDeclaration> QXmlStreamNotationDeclarations;
     
    class Q_XMLSTREAM_EXPORT QXmlStreamEntityDeclaration {
        QXmlStreamStringRef m_name, m_notationName, m_systemId, m_publicId, m_value;
        void *reserved;
     
        friend class QXmlStreamReaderPrivate;
    public:
        QXmlStreamEntityDeclaration();
        ~QXmlStreamEntityDeclaration();
        QXmlStreamEntityDeclaration(const QXmlStreamEntityDeclaration &);
        QXmlStreamEntityDeclaration& operator=(const QXmlStreamEntityDeclaration &);
        inline QStringRef name() const { return m_name; }
        inline QStringRef notationName() const { return m_notationName; }
        inline QStringRef systemId() const { return m_systemId; }
        inline QStringRef publicId() const { return m_publicId; }
        inline QStringRef value() const { return m_value; }
        inline bool operator==(const QXmlStreamEntityDeclaration &other) const {
            return (name() == other.name()
                    && notationName() == other.notationName()
                    && systemId() == other.systemId()
                    && publicId() == other.publicId()
                    && value() == other.value());
        }
        inline bool operator!=(const QXmlStreamEntityDeclaration &other) const
            { return !operator==(other); }
    };
     
    Q_DECLARE_TYPEINFO(QXmlStreamEntityDeclaration, Q_MOVABLE_TYPE);
    typedef QVector<QXmlStreamEntityDeclaration> QXmlStreamEntityDeclarations;
     
     
    class Q_XMLSTREAM_EXPORT QXmlStreamEntityResolver
    {
    public:
        virtual ~QXmlStreamEntityResolver();
        virtual QString resolveEntity(const QString& publicId, const QString& systemId);
        virtual QString resolveUndeclaredEntity(const QString &name);
    };
     
    #ifndef QT_NO_XMLSTREAMREADER
    class Q_XMLSTREAM_EXPORT QXmlStreamReader {
        QDOC_PROPERTY(bool namespaceProcessing READ namespaceProcessing WRITE setNamespaceProcessing)
    public:
        enum TokenType {
            NoToken = 0,
            Invalid,
            StartDocument,
            EndDocument,
            StartElement,
            EndElement,
            Characters,
            Comment,
            DTD,
            EntityReference,
            ProcessingInstruction
        };
     
     
        QXmlStreamReader();
        QXmlStreamReader(QIODevice *device);
        QXmlStreamReader(const QByteArray &data);
        QXmlStreamReader(const QString &data);
        QXmlStreamReader(const char * data);
        ~QXmlStreamReader();
     
        void setDevice(QIODevice *device);
        QIODevice *device() const;
        void addData(const QByteArray &data);
        void addData(const QString &data);
        void addData(const char *data);
        void clear();
     
     
        bool atEnd() const;
        TokenType readNext();
     
        bool readNextStartElement();
        void skipCurrentElement();
     
        TokenType tokenType() const;
        QString tokenString() const;
     
        void setNamespaceProcessing(bool);
        bool namespaceProcessing() const;
     
        inline bool isStartDocument() const { return tokenType() == StartDocument; }
        inline bool isEndDocument() const { return tokenType() == EndDocument; }
        inline bool isStartElement() const { return tokenType() == StartElement; }
        inline bool isEndElement() const { return tokenType() == EndElement; }
        inline bool isCharacters() const { return tokenType() == Characters; }
        bool isWhitespace() const;
        bool isCDATA() const;
        inline bool isComment() const { return tokenType() == Comment; }
        inline bool isDTD() const { return tokenType() == DTD; }
        inline bool isEntityReference() const { return tokenType() == EntityReference; }
        inline bool isProcessingInstruction() const { return tokenType() == ProcessingInstruction; }
     
        bool isStandaloneDocument() const;
        QStringRef documentVersion() const;
        QStringRef documentEncoding() const;
     
        qint64 lineNumber() const;
        qint64 columnNumber() const;
        qint64 characterOffset() const;
     
        QXmlStreamAttributes attributes() const;
     
        enum ReadElementTextBehaviour {
            ErrorOnUnexpectedElement,
            IncludeChildElements,
            SkipChildElements
        };
        QString readElementText(ReadElementTextBehaviour behaviour);
        QString readElementText();
     
        QStringRef name() const;
        QStringRef namespaceUri() const;
        QStringRef qualifiedName() const;
        QStringRef prefix() const;
     
        QStringRef processingInstructionTarget() const;
        QStringRef processingInstructionData() const;
     
        QStringRef text() const;
     
        QXmlStreamNamespaceDeclarations namespaceDeclarations() const;
        void addExtraNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaraction);
        void addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclaractions);
        QXmlStreamNotationDeclarations notationDeclarations() const;
        QXmlStreamEntityDeclarations entityDeclarations() const;
        QStringRef dtdName() const;
        QStringRef dtdPublicId() const;
        QStringRef dtdSystemId() const;
     
     
        enum Error {
            NoError,
            UnexpectedElementError,
            CustomError,
            NotWellFormedError,
            PrematureEndOfDocumentError
        };
        void raiseError(const QString& message = QString());
        QString errorString() const;
        Error error() const;
     
        inline bool hasError() const
        {
            return error() != NoError;
        }
     
        void setEntityResolver(QXmlStreamEntityResolver *resolver);
        QXmlStreamEntityResolver *entityResolver() const;
     
    private:
        Q_DISABLE_COPY(QXmlStreamReader)
        Q_DECLARE_PRIVATE(QXmlStreamReader)
        QScopedPointer<QXmlStreamReaderPrivate> d_ptr;
     
    };
    #endif // QT_NO_XMLSTREAMREADER
     
    #ifndef QT_NO_XMLSTREAMWRITER
     
    class QXmlStreamWriterPrivate;
     
    class Q_XMLSTREAM_EXPORT QXmlStreamWriter
    {
        QDOC_PROPERTY(bool autoFormatting READ autoFormatting WRITE setAutoFormatting)
        QDOC_PROPERTY(int autoFormattingIndent READ autoFormattingIndent WRITE setAutoFormattingIndent)
    public:
        QXmlStreamWriter();
        QXmlStreamWriter(QIODevice *device);
        QXmlStreamWriter(QByteArray *array);
        QXmlStreamWriter(QString *string);
        ~QXmlStreamWriter();
     
        void setDevice(QIODevice *device);
        QIODevice *device() const;
     
    #ifndef QT_NO_TEXTCODEC
        void setCodec(QTextCodec *codec);
        void setCodec(const char *codecName);
        QTextCodec *codec() const;
    #endif
     
        void setAutoFormatting(bool);
        bool autoFormatting() const;
     
        void setAutoFormattingIndent(int spacesOrTabs);
        int autoFormattingIndent() const;
     
        void writeAttribute(const QString &qualifiedName, const QString &value);
        void writeAttribute(const QString &namespaceUri, const QString &name, const QString &value);
        void writeAttribute(const QXmlStreamAttribute& attribute);
        void writeAttributes(const QXmlStreamAttributes& attributes);
     
        void writeCDATA(const QString &text);
        void writeCharacters(const QString &text);
        void writeComment(const QString &text);
     
        void writeDTD(const QString &dtd);
     
        void writeEmptyElement(const QString &qualifiedName);
        void writeEmptyElement(const QString &namespaceUri, const QString &name);
     
        void writeTextElement(const QString &qualifiedName, const QString &text);
        void writeTextElement(const QString &namespaceUri, const QString &name, const QString &text);
     
        void writeEndDocument();
        void writeEndElement();
     
        void writeEntityReference(const QString &name);
        void writeNamespace(const QString &namespaceUri, const QString &prefix = QString());
        void writeDefaultNamespace(const QString &namespaceUri);
        void writeProcessingInstruction(const QString &target, const QString &data = QString());
     
        void writeStartDocument();
        void writeStartDocument(const QString &version);
        void writeStartDocument(const QString &version, bool standalone);
        void writeStartElement(const QString &qualifiedName);
        void writeStartElement(const QString &namespaceUri, const QString &name);
     
    #ifndef QT_NO_XMLSTREAMREADER
        void writeCurrentToken(const QXmlStreamReader &reader);
    #endif
     
    private:
        Q_DISABLE_COPY(QXmlStreamWriter)
        Q_DECLARE_PRIVATE(QXmlStreamWriter)
        QScopedPointer<QXmlStreamWriterPrivate> d_ptr;
    };
    #endif // QT_NO_XMLSTREAMWRITER
     
    QT_END_NAMESPACE
     
    QT_END_HEADER
     
    #endif // QT_NO_XMLSTREAM
    #endif // QXMLSTREAM_H

  8. #8
    Responsable Qt & Livres


    Avatar de dourouc05
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2008
    Messages
    26 754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2008
    Messages : 26 754
    Par défaut
    Le bon fichier qu'on demandait, c'était lui : http://www.eurosport.fr/football/lig.../rss-flash.xml, vu dans ton code. Le fichier XML : c'est le seul qui a du XML dans le nom . Enfin, je suppose que c'est lui, je n'ai jamais fait que survoler le code pour le moment...

    Aussi, c'eût été bien de préciser directement l'avant-dernier fichier, ça permet de comprendre la ligne d'erreur que tu nous montres au début.

    À y regarder de plus près, il me semble que c'est cette ligne qui te pose problème :

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    <atom:link href="http://www.eurosport.fr/rss.xml" rel="self" type="application/rss+xml" />

    Tu devrais charger le fichier quelque part, puis y supprimer la chaîne avant de réinjecter le tout dans ton aprseur XML.

    (Et tu m'as fait mettre les doigts sur un site de foot ! Voilà ce que ça mérite : !).
    Vous souhaitez participer aux rubriques Qt (tutoriels, FAQ, traductions) ou HPC ? Contactez-moi par MP.

    Créer des applications graphiques en Python avec PyQt5
    Créer des applications avec Qt 5.

    Pas de question d'ordre technique par MP !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. probleme erreur xml
    Par bubu92 dans le forum Général Conception Web
    Réponses: 0
    Dernier message: 02/05/2008, 10h05
  2. probleme IE + XML
    Par hobbes80 dans le forum XSL/XSLT/XPATH
    Réponses: 17
    Dernier message: 03/06/2005, 09h21
  3. Probleme erreur 241.
    Par FilipeVV dans le forum MS SQL Server
    Réponses: 15
    Dernier message: 18/02/2005, 11h50
  4. Réponses: 2
    Dernier message: 07/01/2005, 20h40
  5. [FLASH MX] Probleme avec XML
    Par celina5880 dans le forum Flash
    Réponses: 4
    Dernier message: 16/12/2004, 19h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo