2 Replies - 655 Views - Last Post: 30 July 2009 - 01:52 PM

#1 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

C++ XML library

Posted 30 July 2009 - 11:23 AM

Just playing with a few concepts on an xml library for C++. I know there are already solutions for stuff like this, but I like to make my own. :)

I'm currently considering using two interfaces for retrieving data from an XML file. One which is fairly "linear", and a basic SQL-like query language called XQL (XML Query Language)

Example usage will be
Get a simple element:
string info = xml_document->get_element("usergroup.user[0].name");


Get a result:
xql_result res = xml_base->exec_xql("{CASE INSENSITIVE} select user.age from usergroup where user.name = 'danny'");


Example usage of xql_result would be something along the lines of:
if(res.count() > 0) {
    xql_row row;
    while(row = res.fetch_row()) {
        cout << row["age"]; // string
    }
}



The XML would have a structure such as:
<usergroup>
	<user>
		<name>Danny</name>
		<age>19</age>
	</user>
</usergroup>


Thoughts / comments? :) I'm currently working on the parser to read the information from the file, very early stages right now.

This post has been edited by gabehabe: 30 July 2009 - 11:23 AM


Is This A Good Question/Topic? 0
  • +

Replies To: C++ XML library

#2 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: C++ XML library

Posted 30 July 2009 - 11:48 AM

Oh, and of course you could also have an XML document like this:

<usergroup>
    <user name="danny" age=19 />
</usergroup>


:)
Was This Post Helpful? 0
  • +
  • -

#3 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: C++ XML library

Posted 30 July 2009 - 01:52 PM

**update**

Parser is now working with basic files. Currently must have spaces between tags, but it's not a big deal. Simple fix, just haven't gotten around to it yet. *HOWEVAR*

Check it out.
Attached Image

Crap, forgot my own spec. Will shift the "array" indexer over a bit. usergroup.users[0].name

Fixed. :) Also, get_element is now functional. Just need to implement the query lang and I'll sort a release.

This post has been edited by gabehabe: 30 July 2009 - 02:13 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1