Welcome, Guest.
Please login or register.
XML parser
Forum Login
Login Name: Create a new account
Password:     Forgot password

XBLite Forum    General Boards    XBLite Programming  ›  XML parser
Users Browsing Forum
No Members and 1 Guests

XML parser  This thread currently has 6,642 views. Print Print Thread
1 Pages 1 Recommend Thread
Spyke
September 2, 2008, 11:16am Report to Moderator Report to Moderator

Baby Member
Posts: 11
I've just started using xblite and I'm impressed so far. I've got a long way through a short project in the last couple of days.

Does anyone know or have any routines to parse an xml file? I need to find tags, extract the attributes and data values, and put changed elements back again.

If these exist it would save me some time and would be much appreciated!

Spyke
Logged Offline
Private Message Private message
XBLiteAdmin
September 2, 2008, 11:54am Report to Moderator Report to Moderator
Administrator Group
Posts: 44
There is a xml library available in the xblite files area on googlegroups:

http://groups-beta.google.com/group/xblite/files

I think the latest version is gxml-v2.3.8.7z (a 7zip file).

ciao,
D.
Logged Offline
Site Site Private Message Private message Reply: 1 - 11
Spyke
September 2, 2008, 12:05pm Report to Moderator Report to Moderator

Baby Member
Posts: 11
Excellent! Many thanks for the quick reply. I'll take a look.

Cheers,
Spyke
Logged Offline
Private Message Private message Reply: 2 - 11
Rhett Thompson
September 2, 2008, 12:31pm Report to Moderator Report to Moderator

Baby Member
Posts: 23
Hi,

Quoted Text
put changed elements back again


Presently, there isn't a function to do this, as it is a very trivial thing to accomplish.  However, I can see why this would be useful, so when I get home today I'll code it and update the library in the group.

Later.
Logged Offline
Site Site Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 3 - 11
Spyke
September 2, 2008, 2:48pm Report to Moderator Report to Moderator

Baby Member
Posts: 11
Hi Rhett,

Your functions look like exactly what I need, but I'm having difficulty getting the library to compile properly. The basic.x example builds fine, but then reports that it can't find gxml.dll (which I put in the programs folder under my xblite directory). When I put a copy of gxml.dll in the same folder as the compiled basic.exe it runs fine.

Then when I simply add the line IMPORT "gxml" to an existing project it builds OK, but when I try to compile in XSED I get the error:

C:\xblite\lib\gxml.lib : error LNK1125: Conflicting subsystem

Here's what I'm linking:

link /entry:WinMain /NODEFAULTLIB /SUBSYSTEM:WINDOWS,4.0 /INCREMENTAL:NO /RELEASE /NOLOGO /OPT:REF /ALIGN:4096 -out:Test.exe Test.obj Test.rbj xbl.lib xsx.lib gdi32.lib user32.lib kernel32.lib shell32.lib comctl32.lib comdlg32.lib msvcrt.lib advapi32.lib gxml.lib xblib.lib kernel32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib

I've obviously not got things installed correctly, but I've reinstalled xblite, run the install program to set the registry, rebooted, and then extracted the gxml folders into xblite again, and I still get the errors. I've been reading the documentation but I can't figure this out. Sorry!

(I've extracted the contents of each of the folders in your archive under gxml-v2.3.8 to the same folder under xblite.)

Spyke

Logged Offline
Private Message Private message Reply: 4 - 11
Spyke
September 2, 2008, 4:52pm Report to Moderator Report to Moderator

Baby Member
Posts: 11
Quoted from Rhett Thompson
Presently, there isn't a function to do this, as it is a very trivial thing to accomplish.  However, I can see why this would be useful, so when I get home today I'll code it and update the library in the group.

Rhett, I've been trying out your functions today (after loading them directly into my test project). Is it possible to add a function that's effectively the reverse of XmlLoadFromFile?

e.g.

XmlSaveToFile (XMLNODE root, fileName$)

I imagine that this would have to rebuild a string containing the full text of the xml file from the data held in the root structure, and then save the results using XstSaveString(), but is there any easier way to do this than by recursing through the structure?

Theoretically running XmlSaveToFile after XmlLoadFromFile should produce a file technically identical to the original (i.e. except for trimmed white space).

Spyke
Logged Offline
Private Message Private message Reply: 5 - 11
Rhett Thompson
September 2, 2008, 5:00pm Report to Moderator Report to Moderator

Baby Member
Posts: 23
That is strange. Are you sure you're using Xblite 2.4?  It sounds like you are linking an older version of xbl.lib than the one compiled, take a look at this post where Guy was having a similar problem -> http://groups.google.com/group/xblite/browse_thread/thread/38b2cf507b16a504#.  If that's not what's the problem then you might consider upgrading you linker.

Later.
Logged Offline
Site Site Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 6 - 11
Spyke
September 2, 2008, 5:33pm Report to Moderator Report to Moderator

Baby Member
Posts: 11
Thanks Rhett.

Updating the linker to the one on Callum's site worked. (I was using xblite 2.40.)

Spyke
Logged Offline
Private Message Private message Reply: 7 - 11
Rhett Thompson
September 2, 2008, 6:10pm Report to Moderator Report to Moderator

Baby Member
Posts: 23
Hi,

Quoted Text
Rhett, I've been trying out your functions today (after loading them directly into my test project). Is it possible to add a function that's effectively the reverse of XmlLoadFromFile?


I'm definitely going to add this as soon as I get home.

Quoted Text
I imagine that this would have to rebuild a string containing the full text of the xml file from the data held in the root structure, and then save the results using XstSaveString(), but is there any easier way to do this than by recursing through the structure?


You are right, but the only way I think it would work would be through recursion.  This isn't that big of a deal as it would only have to test for each parent (of each node), and build the string...which is fairly cheap considering.  I'll see if I can come up with some other method, but I think a simple recursive function would do the trick better than anything else.  gxml is innately setup for things like this (as evidence in the "pointing" nature of how nodes and things are referenced), so it will hopefully be very simple and I can post it in a few hours.  Like nearly every "utility" function, it will probably just use the existing API.  I'll likely use the "basic" node retrieval functions, so I'll probably use something like this:

Code
XMLNODE node
n=XmlGetNodes()
FOR i=1 TO n
	node=XmlGetNode(i)
NEXT i


P.S.  To be honest, one of the first versions actually had this exact functionality, except it was called XmlCompileDocument$() or something.
Logged Offline
Site Site Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 8 - 11
Spyke
September 2, 2008, 6:35pm Report to Moderator Report to Moderator

Baby Member
Posts: 11
More thoughts on my post above. The saving to file part is easy, what's needed is the step that converts a node, with all its children, back into an xml string, so a new function called something like XmlSaveToString. This would allow us to break out a small part of an xml file, manipulate it using XmlLoadFromString, and then stitch the new bit back in.

Or am I being dense and missing something obvious?

Spyke (quite possible being dense)

---

Edit: Posted this without seeing your post above. Relieved that I probably wasn't being dense!  
Logged Offline
Private Message Private message Reply: 9 - 11
Rhett Thompson
September 3, 2008, 3:50pm Report to Moderator Report to Moderator

Baby Member
Posts: 23
Done! It appears to work fine, I tested it with the biggest, messiest example I could find and no problems.  I'll attach it to a new post in this board, as I can't sign in to Google where I'm at.
Logged Offline
Site Site Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 10 - 11
Spyke
September 4, 2008, 10:01am Report to Moderator Report to Moderator

Baby Member
Posts: 11
Excellent! I'll download it and try it out today.  

Many thanks, Rhett,

Spyke
Logged Offline
Private Message Private message Reply: 11 - 11
1 Pages 1 Recommend Thread
Print Print Thread

XBLite Forum    General Boards    XBLite Programming  ›  XML parser

Thread Rating
There is currently no rating for this thread