0

I'm making a 2D game with LWJGL at the moment. I'm using JDOM as a base for storing information in XML files.

My items.xml file is structured as follows:

<items>
    <item>
        <id>1</id>
        <name>Item</name>
        <description>This is an item</description>
    </item>
</items>

There will be a lot of items in the file. So I want to be able to select a specific item, where the tag matches the given id I want to search for. I understand how to get ALL the information from the file, but how can I get just a specific item?

Darren
  • 1,774
  • 4
  • 21
  • 32

2 Answers2

2

Use xpath - I use it at work when handling xml files in java. It's pretty nice. http://www.ibm.com/developerworks/library/x-javaxpathapi/

Mads
  • 724
  • 3
  • 10
  • Thanks, I had seen a couple things about that, but wasn't sure if it was what I was looking for. – Darren Apr 16 '12 at 22:33
0

If you trully wish SQL for XML you should also check out XQuery. It's another technology centered around XPath. I believe SaxonB provides an opensource implementation of it. It may be overkill to actually use it - depending on the complexity of your XML.

predi
  • 5,528
  • 32
  • 60