Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 102
Registered: ‎03-01-2010
My Device: 8310
My Carrier: Ingenieur

SQL with XML

Hello every one
I have a problem with my Xml file ,and i need your help ;
 so my question is :
i want to show all the document which have the same society  :
i have an xml file ,where we find a lot of document <document > </document>
these documents has some item such as :

<document  >
<item name ="Rsocity"> Society1 </item> 
<item name ="Rtype"> informatique</item>
</document>

<document >
<item name ="Rsocity">Society 2 </item> 
<item name ="Rtype"> informatique</item>
</document >

<document >
<item name ="Rsocity">Society 2 </item> 
<item name ="Rtype">test</item>
</document>

<document >
<item name ="Rsocity">Society1 </item> 
<item name ="Rtype"> kk</item>
</document>
                       
i want to groupe all the documents which has the same society i want to have somthing such this :

+Society1
+Society2   
     |
-Society1
 -informatique   ->open : this will show us all the attribute of the document (show society1 + type =informatiqye )
 -kk                ->open : this will show us all the attribute of the document (show society1 + type =kk )
-Society2  
- informatique  ->open : this will show us all the attribute of the document (show society2 + type =informatique )
 - test             ->open : this will show us all the attribute of the document (show society1 + type =test )

Can you tell me  how can i programm this ,any idea ? i think to use a sql request ,use some thing like group by in SQL ,but i don(t know how can i begin )
i need your help if it's possible .thank you very much .
                              .


 

Thank you very much  :
Best regards ;
 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SQL with XML

Do you know how to use an XML parser?  SAX or DOM?

 

Do you know how to use SQL?

Developer
Posts: 68
Registered: ‎02-05-2009
My Device: Not Specified

Re: SQL with XML

- How does your question relates to SQL? If you have XML data and that what you want to work with, SQL will not help you in any way AFAIK.

 

- Using XQuery (SQL like quiery langage for XML), you can write a query that does the "group by" analog of SQL. But all it does is baically nested loop thing collecting all the things you want for every element in the representative group. So what I am saying, you can try to use XQuery (if you are brave Smiley Happy ) which will mean finding XQUery processor implementation for BB and learning XQuery to construct the needed request or you can just parse the query and use nested loops to solve the problem. Or better yet parse the file and put it into a datastructure (if it fits into memory) and then process the DS, which will most likely be much more efficient than reparsing the XML several times.

 

I am assuming here that you are familiar with basics of XML and XML parsing (this is exactly what Peter is asking you in the previous post), so in case you do, my post would be useful to you, in case you dont - well you need to get a grasp of XML first - there's no silver bulet unfortunately (yet... Smiley Happy )

Highlighted
Trusted Contributor
Posts: 102
Registered: ‎03-01-2010
My Device: 8310
My Carrier: Ingenieur

Re: SQL with XML

Hello ;

 

thank you peter ,and :

 

So ,as you know , iam still a student , idon't have experiences in BB devloppement ,so i think that 


Instead of using SQL, i can also use data structures for storing the data and search them for what i need to display.

i will Create a class named Document. Have the attributes of document as Document's class variables.

....................;;and see what's  can give me !!!!!

 

 

thank youuu Smiley Happy