×

Discussion Board

Results 1 to 9 of 9

Thread: Reg:parsing

Threaded View

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    159

    Reg:parsing

    Hi actually im facing a problem in parsing my soap response... my application is getting crashed...im trying to parse the following xml content,

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <ImportIncomingSMSResponse xmlns="http://www.atom8itsolutions.com/">
    <ImportIncomingSMSResult>string</ImportIncomingSMSResult>
    </ImportIncomingSMSResponse>
    </soap:Body>
    </soap:Envelope>

    im using csendonfragement for parsing, but my application crashes in the line

    reader->ParseL(fss, KToBeParsed);

    for ur reference ill post my code below,

    TBuf8<900> SMSText;
    TBuf<20> inputtext1;
    _LIT(KTxt2,"success");
    inputtext1.Copy(KTxt2);
    TBuf8<150> Text;
    SMSText.Copy(_L("<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><ImportIncomingSMSResponse xmlns='http://www.atom8itsolutions.com/'><ImportIncomingSMSResult>"));
    SMSText.Append( inputtext1);
    Text.Copy(_L("</ImportIncomingSMSResult></ImportIncomingSMSResponse></soap:Body></soap:Envelope>"));
    SMSText.Append(Text);

    HBufC* buf16 = HBufC::NewLC(SMSText.Length());
    buf16->Des().Copy(SMSText);
    //CleanupStack::PopAndDestory(buf16);



    // create new XML reader and push it to the cleanupstack
    CSenXmlReader* reader = CSenXmlReader::NewL();
    CleanupStack::PushL(reader);

    //create a CSenDomFragment
    CSenDomFragment* pBase = CSenDomFragment::NewL();
    CleanupStack::PushL(pBase);

    //the XML document to be parsed
    _LIT(KToBeParsed, "buf16");

    // TBuf8<160> SMSText;

    // SMSText.Copy(_L("<messages><message><from>some number</from><content>some content</content></message><message><from>some number</from><content>some content</content></message></messages>"));
    //_LIT(KToBeParsed, "SMSText");
    //open a filesession
    RFs fss;
    User::LeaveIfError(fss.Connect());
    CleanupClosePushL(fss);
    //must set the content handler
    reader->SetContentHandler(*pBase);
    // and the reader
    pBase->SetReader(*reader);
    //do the parsing
    reader->ParseL(fss, KToBeParsed);

    //after the parsing, get the elements:
    RPointerArray<CSenElement>& array = pBase->AsElement().ElementsL();

    //start the listing of the elements, first level is 1
    ListNodesL(array,1);
    CleanupStack::PopAndDestroy(3); // pBase, fss, reader
    // return retVal;
    }

    // The listing of the elements is done in ListNodesL function:
    void CSmsHandler :: ListNodesL(RPointerArray <CSenElement>& aArray,
    int aLevel)
    {
    _LIT(KNewLine, "\n");
    _LIT(KNoContent,"NO CONTENT");
    _LIT(KDepthFormatString, "lev%d: ");
    int j=0;
    TBuf<150> pNumber;
    TBuf<150> pMessage;

    TInt size = aArray.Count();
    for(TInt i=0; i<size; i++)
    {

    //get an element
    CSenElement* pElement = aArray[i];

    TBool hasActualContent = EFalse;
    if( pElement->HasContent() )
    {
    //get the content of the element
    TPtrC8 content = pElement->Content();

    //to a HBufC, notice "LC"
    HBufC *pContent = SenXmlUtils::ToUnicodeLC(content);

    //print current depth (“level”)

    //trim possible whitespace characters
    pContent->Des().Trim();
    //if there is content after the trimming
    if( pContent->Length() > 0)
    {
    hasActualContent = ETrue;
    // aConsole.Printf(*pContent);
    RDebug::Print(*pContent);
    if(j==0)
    {
    //_LIT(KTxt1,*pContent);

    pNumber.Copy(*pContent);
    j++;
    }
    else
    {
    // _LIT(Msg,*pContent);
    //TBuf<150> pMessage;
    pMessage.Copy(*pContent);
    j++;
    }
    }
    //destroy pContent
    CleanupStack::PopAndDestroy(pContent);
    }
    if( !hasActualContent)
    {
    // aConsole.Printf(KNoContent);
    }

    //get the first child
    CSenElement* child = pElement->Child(1);
    RDebug::Print( _L("RDebug Hello") );

    //check if element has childs
    if( child )
    {
    //get the child elements
    RPointerArray<CSenElement>& tree = pElement->ElementsL();


    //list child elements by a recursive call
    ListNodesL(tree, ++aLevel);
    }
    aLevel--;
    if (j>1 && j<3)
    {
    this->SendSmsL(pNumber,pMessage);

    j=0;
    }
    else if(j>=3)
    {
    break;
    }
    }

    // this->SendL(pNumber,pMessage);
    } //for loop ends


    can any one tell me a reason y my application crashes.... waiting for ur replies
    Last edited by ranjini; 2010-08-07 at 08:08.

Similar Threads

  1. Reg: convertion
    By ranjini in forum Symbian
    Replies: 6
    Last Post: 2010-07-31, 06:51
  2. Reg:parsing
    By gurubai in forum Symbian
    Replies: 2
    Last Post: 2010-07-08, 12:20
  3. Reg: issue in parsing xml
    By raguuu in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2010-07-06, 13:05
  4. Reg non repudiation
    By praveena in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2006-02-22, 22:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •