qt-2.2.1 xml parsing

Discussion in 'XML' started by deodiaus, Apr 21, 2004.

  1. deodiaus

    deodiaus Guest

    I am trying to read this xml
    ---------------- begin xml ----------
    <Aqrun2dCapDialog>
    <AqRSDialog>
    <userprefixfield></userprefixfield>
    <m_rsName>RunScripts.ksh</m_rsName>
    </AqRSDialog>
    <singlevalfield>0.1</singlevalfield>
    <rangefromvalfield>0.1</rangefromvalfield>
    <rangetovalfield></rangetovalfield>
    <varlist><varitem0>M1 Total thickness From: 0.135 To: 0.139 Step:
    0.001</varitem0>
    <varitem1>M1 Signal line width 0.1,.2</varitem1>
    </varlist>
    </Aqrun2dCapDialog>
    ------------- end xml -----------------
    but having a problem in that the code seems to not treat <varitem0>
    <varitem0> independently, as 2 separate fields, rather as 1 entitiy,
    i.e. the text reads

    tagName={varitem} tagText={M1 Total thickness From: 0.135 To: 0.139
    Step:
    0.001M1 Signal line width 0.1,.2}

    rather than the desired output

    tagName={varitem0} tagText={M1 Total thickness From: 0.135 To: 0.139
    Step:
    0.001}
    tagName={varitem1} tagText={M1 Signal line width 0.1,.2}


    using the sample QT code from www.trolltech.com 's help

    if (AqmainWindow::m_pDoc) delete AqmainWindow::m_pDoc;
    AqmainWindow::m_pDoc = new QDomDocument( "mydocument" );
    QFile f( filenameAqs.latin1() );
    if ( !f.open( IO_ReadOnly ) )
    return;
    if ( !AqmainWindow::m_pDoc->setContent( &f ) ) {
    f.close();
    return;
    }
    f.close();
    QDomElement docElem = AqmainWindow::m_pDoc->documentElement();
    if( !docElem.isNull() ) { // the node was really an element.
    #ifdef _DEBUG
    cout <<" documentElementName={" << docElem.tagName() << "}" <<
    endl;
    #endif//_DEBUG
    }
    QDomNode n = docElem.firstChild();
    while( !n.isNull() ) {
    QDomElement e = n.toElement();
    if( !e.isNull() ) { // the node was really an element.
    #ifdef _DEBUG
    cout <<" tagName={" << e.tagName() << "} tagText={" <<
    e.text().latin1()<< "}" << endl;
    #endif//_DEBUG
    if (e.tagName() == "Aqrun2dCapDialog" ) {
    Aqrun2dCapDialog::m_bSettingsAqsExist = true;

    }
    } n = n.nextSibling();
    }

    ------------
    How does one have many different fields of text in XML?
     
    deodiaus, Apr 21, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Per Magnus L?vold
    Replies:
    0
    Views:
    1,424
    Per Magnus L?vold
    Nov 15, 2004
  2. Greg Wogan-Browne
    Replies:
    1
    Views:
    861
    Uche Ogbuji
    Jan 28, 2005
  3. Replies:
    2
    Views:
    511
  4. John Levine
    Replies:
    0
    Views:
    756
    John Levine
    Feb 2, 2012
  5. Erik Wasser
    Replies:
    5
    Views:
    500
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page