xml parser

Login to reply to this topic.
Thu, 2008-07-24 07:29
Joined: 2008-03-06
Forum posts: 15

Hi All,
I am trying to fetch the location and service providers value for a particular number from the xml code below

<?xml version="1.0" ?>
<knowcarrier>
<mobile>
<number>98450,98451,98452</number>
<serviceprovider>AIRTEL</serviceprovider >
<location>Karnataka</location>
</mobile>
<mobile>
<number>94450,94451,94452</number>
<serviceprovider>BSNL</serviceprovider >
<location>Karnataka</location>
</mobile>
<mobile>
<number>98440,98441,98442</number>
<serviceprovider>SPICE</serviceprovider >
<location>Karnataka</location>
</mobile>

Eg: if i am searching for the no 98451, and on successfull search, it should display only "AIRTEL","Karnataka". but i am getting all the data in the file.
can anyone plz help me.

Thanks in advance
Veekay


Thu, 2008-07-24 08:23
Joined: 2007-09-24
Forum posts: 88
Re: xml parser

Hi veekay
Sorry I couldn't completely understand you ,

but i am getting all the data in the file.

Any way
These are some step for getting AIRTEL and Karnataka from your XML file: First Read complete data in Descriptor
1-> Search for 98451( you are successful as you mentioned above )
2->Search for
<serviceprovider>
I think This tag is unique across all Xml file (Now you have got AIRTEL )
3->Search for
<location>
I think This tag is unique across all Xml file (Now you have got Karnataka )
follow above three step :
If you encounter any problem , post that here

Thanks and Regard
Praveen Kumar Sharma

Thu, 2008-07-24 08:53
Joined: 2008-03-06
Forum posts: 15
Re: xml parser

Thanks Praveen, But how to get the value between the tag.
like in the xml parser example... what shud be written in the function

OnStartElementL( const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode )
and
OnContentL( const TDesC8 &aBytes, TInt aErrorCode )

i am sorry if i am asking the very basics.

thanks

Thu, 2008-07-24 09:45
Joined: 2007-09-24
Forum posts: 88
Re: xml parser
Thu, 2008-07-24 11:13
Joined: 2008-03-06
Forum posts: 15
Re: xml parser

Thanks praveen, My code is working now Eye-wink Eye-wink

Thu, 2008-07-24 11:33
Joined: 2007-09-24
Forum posts: 88
Re: xml parser

Hi veekay Smiling Smiling
Can you please explain where was you wrong in your code and what you did to make it workable

Thanks and Regard
Praveen Kumar Sharma

Thu, 2008-07-24 13:50
Joined: 2008-03-06
Forum posts: 15
Re: xml parser

I made changes in OnContentL( const TDesC8 &aBytes, TInt aErrorCode )
i included few line

if(buffer->Find(_L("98452"))!=KErrNotFound )
{
aFlag = KNumberFound;

}
if(aFlag == KFetchInfo)
{
if(iNumOfDataToFetch<4)
{
AppendText( *buffer );
iNumOfDataToFetch++;
}
}

and in
OnStartElementL( const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode )
i included

if(aFlag == KNumberFound)
{
aFlag = KFetchInfo;
}
thats all Smiling

Thu, 2008-07-24 13:45
Joined: 2007-09-24
Forum posts: 88
Re: xml parser

Thanks veekay
We all should complete the thread with solution , because the solution might be useful for others
Thanks and Regard
Praveen Kumar Sharma

  • Login to reply to this topic.