×

Discussion Board

Results 1 to 15 of 15

Thread: CParser Problem

  1. #1
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    68

    CParser Problem

    I am using the CParser example given on this forum to make a XML Parser. The Header file is as below:

    #ifndef __XMLHANDLER_H__
    #define __XMLHANDLER_H__
    // INCLUDE FILES
    #include <e32base.h>
    #include <f32file.h>
    //Link against efsrv.lib
    #include <xml\contenthandler.h> // for MContentHandler
    #include <xml\parser.h> // for CParser
    // CLASS DECLARATION

    using namespace Xml;

    class CXmlHandler: public CActive, MContentHandler

    {
    public: // Constructors and destructor

    static CXmlHandler* NewL();
    static CXmlHandler* NewLC();
    virtual ~CXmlHandler();

    public: // Public methods
    void StartParsingWithAoL( const TDesC& aFileName );

    private: // Constructors

    CXmlHandler();
    void ConstructL();

    private: // from CActive

    void DoCancel();
    void RunL();

    private: // from MContentHandler

    void OnStartDocumentL( const RDocumentParameters &aDocParam, TInt aErrorCode );
    void OnEndDocumentL( TInt aErrorCode );
    void OnStartElementL( const RTagInfo &aElement, const RAttributeArray &aAttributes, TInt aErrorCode );
    void OnEndElementL( const RTagInfo &aElement, TInt aErrorCode );
    void OnContentL( const TDesC8 &aBytes, TInt aErrorCode );
    void OnStartPrefixMappingL( const RString &aPrefix, const RString &aUri, TInt aErrorCode );
    void OnEndPrefixMappingL( const RString &aPrefix, TInt aErrorCode );
    void OnIgnorableWhiteSpaceL( const TDesC8 &aBytes, TInt aErrorCode );
    void OnSkippedEntityL( const RString &aName, TInt aErrorCode );
    void OnProcessingInstructionL( const TDesC8 &aTarget, const TDesC8 &aData, TInt aErrorCode);
    void OnError( TInt aErrorCode );
    TAny *GetExtendedInterface( const TInt32 aUid );

    private: // Private data
    CParser* iParser;

    HBufC8* iBuffer;

    RFile iFile;

    };
    #endif /* __XMLHANDLER_H__ */


    When I am trying to use it, the app crashes in the following function:

    void CXmlHandler::ConstructL()
    {
    iParser = CParser::NewL( KXmlMimeType, *this );
    }


    With the system error -17551 which says KXmlPluginNotFound

    I am using the trial versions of S60 5th edition SDK and Carbide C++ 2.0 both downloaded from this site.

    What can be the problem. KXmlMimeType and other values used are correct.

    Plz Help
    Last edited by contra03; 2009-11-02 at 06:18.

  2. #2
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: CParser Problem

    How have you defined KXmlMimeType? whats the value in it?

  3. #3
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    68

    Re: CParser Problem

    Yes I have defined it in the same file.

    _LIT8( KXmlMimeType, "C:\\Data\\BuildData.xml" );

    I have shared the C Drive of my desktop as the memory card and copied the BuildData.xml file from there to the C drive i.e. the phone memory. ( I am using a Emulator)

  4. #4
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: CParser Problem

    Quote Originally Posted by contra03 View Post
    Yes I have defined it in the same file.

    _LIT8( KXmlMimeType, "C:\\Data\\BuildData.xml" );

    I have shared the C Drive of my desktop as the memory card and copied the BuildData.xml file from there to the C drive i.e. the phone memory. ( I am using a Emulator)
    AFAIK it should be something like "utf-8/xml" or "text/xml". It takes MIME type and not file name or path.

  5. #5
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    68

    Re: CParser Problem

    How do I give it MIME type. I mean i have a BuildData.xml file in the phone memory. How do I convert it to a MIME type.

  6. #6
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: CParser Problem

    Have you tried using _LIT8( KXmlMimeType, "text/xml" );

  7. #7
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    181

    Re: CParser Problem

    Tried using 'BuildData/xml' .

    Doesnt work

  8. #8
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    181

    Re: CParser Problem

    Thanks its working now.

    Now that the parsing has begun, how do I access the various tags and retrieve the value of the attributes. Im new to this s. Plz help

  9. #9
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: CParser Problem

    Quote Originally Posted by nisheethpandey View Post
    Tried using 'BuildData/xml' .

    Doesnt work
    I asked to check if "text/xml" works or not. Not 'BuildData/xml' as it is not a standard mime type.

  10. #10
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: CParser Problem

    Quote Originally Posted by nisheethpandey View Post
    Thanks its working now.

    Now that the parsing has begun, how do I access the various tags and retrieve the value of the attributes. Im new to this s. Plz help
    What did you do to get it working?

  11. #11
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    181

    Re: CParser Problem

    In the mime type I gave 'text/xml' and it worked. Even 'BuildData/xml' doesnt work.

    Now the parsing has begun.
    iParser->ParseBeginL();

    is executing successfully. How do I proceed from here.

  12. #12
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: CParser Problem

    Quote Originally Posted by nisheethpandey View Post
    In the mime type I gave 'text/xml' and it worked. Even 'BuildData/xml' doesnt work.

    Now the parsing has begun.
    iParser->ParseBeginL();

    is executing successfully. How do I proceed from here.
    As I said 'BuildData/xml' is not a recognized mime type and would not work.

    Quote Originally Posted by nisheethpandey View Post
    How do I proceed from here.
    Please try debugging the above said example you are referring to and learn its working also check the SDK doc for more explanation. Once you have gone thru the doc and then if some issues are there you can post your queries here.

  13. #13
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: CParser Problem

    Nokia Developer Wiki Moderation team

  14. #14
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    68

    Re: CParser Problem

    OK so I started to parse the XML file. However I am stuck at a point.

    I can read the attributes of an element using aAttributes in the OnStartElementL function.

    TArray<Xml::RAttribute> a = aAttributes.Array();
    RString val = a[0].Value();


    But how Do I get the text stored in the attribute. I am using the above code but on debugging it just shows the address of val and not the value stored in it. So how do I extract these attribute values from the XML File.

    Plz Help

  15. #15
    Regular Contributor
    Join Date
    Apr 2008
    Location
    India
    Posts
    477

    Re: CParser Problem

    Quote Originally Posted by contra03 View Post
    OK so I started to parse the XML file. However I am stuck at a point.

    I can read the attributes of an element using aAttributes in the OnStartElementL function.

    TArray<Xml::RAttribute> a = aAttributes.Array();
    RString val = a[0].Value();


    But how Do I get the text stored in the attribute. I am using the above code but on debugging it just shows the address of val and not the value stored in it. So how do I extract these attribute values from the XML File.

    Plz Help
    OnContentL(const TDesC8 &aBytes, TInt aErrorCode) will give u the data.

    Read MContentHandler class u will get valuable information. as this is the main class which will get call back on element start, elemet end, data part start, doc start etc.

Similar Threads

  1. STLPort namespace issue
    By yickhong in forum Open C/C++
    Replies: 0
    Last Post: 2009-04-09, 08:54
  2. SyncML link problem
    By samuel_ in forum Symbian
    Replies: 4
    Last Post: 2009-03-27, 08:02
  3. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  4. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  5. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

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