[Qt-interest] Data Storage for QT Application
Chitrang Srivastava
chitrang.srivastava at gmail.com
Wed Feb 10 13:15:01 CET 2010
OK I am using QXML now; looks to be good; I can insert and read all atleast.
How can i remove an entire tag based on value of its attribute.
For example take this sample XML File
<Country Name="India" Capital="New Delhi" Offset="+05:30"/>
<Country Name="Japan" Capital="Tokyo" Offset="+08:00"/>
<Country Name="France" Capital="Paris" Offset="+02:00"/>
Now I got input as "Japan" ; I want to search my dom tree with this
attribute value and delete the whole tag so it should become;
<Country Name="India" Capital="New Delhi" Offset="+05:30"/>
<Country Name="France" Capital="Paris" Offset="+02:00"/>
I see methods like removeAttribute() ; but counld n't find a method which
delete the tag(QDomElement) based on the value of it attribute.
Any pointers guys on how to do it?
-chits
On Wed, Feb 10, 2010 at 12:29 AM, André Somers <andre at familiesomers.nl>wrote:
> It really sounds like a perfect job for using SQL, but if you find that
> overkill, just use a simple QFile like was suggested below. SQLite is small
> and self-contained, but a bit more work to implement than just using a QMap
> with your pairs, and reading and writing that to/from a file with
> QDataStream since your list is small anyway. If SQL is overkill for you,
> then so is XML, IMHO.
>
> The QMap solution supports all you want, all you need to do is just write
> out your modified QMap again. If you only have a few dozen pairs, that will
> be done in no time at all. If you go for an XML based solution, you’ll have
> the same issue. Only SQL is more efficient there, but for so little rows,
> it’s hardly worth the effort IMO.
>
>
>
> André
>
>
>
> *Van:* qt-interest-bounces at trolltech.com [mailto:
> qt-interest-bounces at trolltech.com] *Namens *Chitrang Srivastava
> *Verzonden:* dinsdag 9 februari 2010 18:42
> *Aan:* Srdjan Todorovic
>
> *CC:* qt-interest at trolltech.com
> *Onderwerp:* Re: [Qt-interest] Data Storage for QT Application
>
>
>
> Hello Friend,
>
> I see their is lot of other options suggested by esteemed members.
>
> Let me put my requirements first.
> record means (Country name,capital, )
>
> Add a record.
> Delete a record(row), based on Country name(A country name will be given
> search the record in table & delete the whole row).
> Retrieve all the records(whole table ).
>
> I see that QSettings cant solve this problem fully (retrive row based on a
> value wouldn't possible).
> I will try XML ; guess needs to create domtree ; query/add /modify and
> write back to xml file.
> Any other suggestion ?
>
> -chits
>
> On Tue, Feb 9, 2010 at 7:00 PM, Srdjan Todorovic <
> todorovic.s at googlemail.com> wrote:
>
> On 09/02/2010, Sean Harmer <sean.harmer at maps-technology.com> wrote:
> > On Tuesday 09 February 2010 13:05:23 Srdjan Todorovic wrote:
>
> >> How about:
> >> setValue("Country_01/Name","France");
> >> setValue("Country_01/Capital","Paris");
> >> setValue("Country_02/Name","Japan")
> >> setValue("Country_02/Capital","Tokyo")
> >>
> >> And you could even have a count saved:
> >> setValue("NumberOfEntries","2"); or similar.
> >>
> >> You can do this in a loop. Does that help?
> >
> > Or you could even use the begin{Read|Write}Array()/endArray() functions
> of
> > QSettings and let that do it for you.
>
> Thanks for that tip. Sadly that's not implemented in my QSettings.
> Hopefully it is for the OP.
>
> Srdjan
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100210/851dfe54/attachment.html
More information about the Qt-interest-old
mailing list