88216

How to store and retrieve objects using XML?

Question:

I have a class called Word with these four attributes: text, caseSensitive, matchSimilar and relevance.

I have 10 categories for these words: (allowDetermining,allowHigh,...,denyDetermining,denyHigh,etc.).

I want to be able to store new words on each categories or retrieve all words from some category. How can I do this.

I think the XML structure should be like this, but I don't know if I'm right:

<allowDetermining> <word> <text>Renato</text> <caseSensitive>true</caseSensitive> <matchSimilar>false</matchSimilar> <relevance>0.75</relevance> </word> </allowDetermining> <allowHigh> ... </allowHigh> ...

At the moment, I'm using the XMLConfiguration class from Apache Commons Configuration. Any idea of how do this using it? And with another library?

Answer1:

Is use of XML a requirement, or just your first idea? For persisting configuration data or working sets, JSON (data) or YAML (configuration) might make more sense and be bit easier to do as well. XML works better for its original use case (text markup), but for data-oriented stuff it is quickly falling out of favor, and for good reason.

Recommend

  • Continuous quantiles of a scatterplot
  • Subprocess in Reading Serial Port Read
  • Where is this gap/margin coming from?
  • Spinner with border
  • Cannot convert a char value to money. The char value has incorrect syntax
  • Is there a chance to get -splash: work for SWT applications that require -XstartOnFirstThread?
  • Scrolling News Ticker Jquery - Issues
  • Using extern @class in order to add a category?
  • “A GKScore must specify a leaderboard.”
  • include dlls in visual studio c++ 2008
  • Sensibility of combined Maven/Ant+Ivy build management for dual platform Desktop/Android deployment?
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • R Split data.frame using a column that represents and on/off switch
  • Pycharm: Marking a folder as 'sources root' is not recursive for subfolders
  • Unable to get column index with table.getColumn method using custom table Model
  • Play WS (2.2.1): post/put large request
  • How do I change content of ComboFieldEditor?
  • Can I display google adwords (AdView) in javafx on android
  • Deserializing XML into class C#
  • Can I make an Android app that runs a web view in Chrome 39?
  • Weird JavaScript statement, what does it mean?
  • Do I've to free mysql result after storing it?
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • SQL merge duplicate rows and join values that are different
  • KeystoneJS: Relationships in Admin UI not updating
  • How to stop GridView from loading again when I press back button?
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal