News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

XML Parser/Edit library

Started by ragdog, February 05, 2017, 09:46:05 PM

Previous topic - Next topic

ragdog

Hello

I search for my new project a XML Parser/Edit library.
Has anyone, a good library and an example ?

Regads,

Zen

RAGDOG,
I started working on an XML library using the .NET Framework, and MABDELOUHAB's Masm32Ref. I thought it would be easy,...but, I thoroughly destroyed it (I must have some advanced form of programming dementia). :bgrin:
However, there are several fairly simple ways to do it, depending on which XML version you have loaded on your (or, the user's computer).
Here is a: Listing of Microsoft XML parser (MSXML) versions. These come with Internet Explorer, and they are implemented as COM interfaces. To use one of these versions from a MASM assembly language program, you will have to call LoadLibrary on the XML library DLL, and then call CoCreateInstance on whichever interface that you want to use. It will require way too much code to be really fun, but, it is possible,...:bgrin: 
You will probably want to read this: MSXML Roadmap, MSDN
Zen

fearless

Could be work a look:

Mini-XML - Tiny XML Library: http://www.msweet.org/projects.php?Z3
Yxml - A small, fast and correct XML parser: https://dev.yorhel.nl/yxml
AsmXml - A very fast XML parser and decoder for x86: http://tibleiz.net/asm-xml/

Might have to compile some of them to lib and convert headers .h to .inc for use with asm

fearless

Done some conversion of the mxml header to an inc file and compiled the visual studio solution to a static lib: https://dl.dropboxusercontent.com/u/17077376/mxml.zip

Also a basic radasm v2 project to test some basics of the mxml nodes/elements just to verify if library is working: https://dl.dropboxusercontent.com/u/17077376/mxmltest.zip

I havent done any extensive tests apart from the ones in the radasm project, and cant say all features/functions are working - but so far the basic tests seem to work - i took the testmxml.c file from the mini-xml source as a basis to work through some of the test steps to use some of the functions.

HSE

Hi fearless!

What version of masm32 are you using?


ml -c -coff -Cp  /I"$I" "mxmltest.Asm"
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: mxmltest.Asm

***********
ASCII build
***********

\Masm32\include\windows.inc(16531) : error A2037: statement not allowed inside structure definition
szText(2): Macro Called From
  \Masm32\include\windows.inc(16531): Include File
\Masm32\include\windows.inc(16531) : error A2008: syntax error : db
szText(3): Macro Called From
  \Masm32\include\windows.inc(16531): Include File
\Masm32\include\windows.inc(16531) : error A2034: must be in segment block
szText(4): Macro Called From
  \Masm32\include\windows.inc(16531): Include File
\Masm32\include\windows.inc(16543) : error A2037: statement not allowed inside structure definition
szText(2): Macro Called From
  \Masm32\include\windows.inc(16543): Include File
\Masm32\include\windows.inc(16543) : error A2008: syntax error : db
szText(3): Macro Called From
  \Masm32\include\windows.inc(16543): Include File
\Masm32\include\windows.inc(16543) : error A2034: must be in segment block
szText(4): Macro Called From
  \Masm32\include\windows.inc(16543): Include File

***********
ASCII build
***********

------------------------------------------
WARNING Duplicate include file windows.inc
------------------------------------------
-----------------------------------------
WARNING duplicate include file user32.inc
-----------------------------------------
-------------------------------------------
WARNING duplicate include file kernel32.inc
-------------------------------------------
----------------------------------------
WARNING duplicate include file gdi32.inc
----------------------------------------
------------------------------------------
WARNING duplicate include file shell32.inc
------------------------------------------
-------------------------------------------
WARNING duplicate include file comctl32.inc
-------------------------------------------
-------------------------------------------
WARNING duplicate include file comdlg32.inc
-------------------------------------------

Error(s) occured.


There is no problem with .incs. szText renamed in mxmltest.inc and debub32.inc. Is there another szText? szText in NMTTDISPINFO

Changing Windows.inc:
link /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /OUT:"mxmltest.exe" "mxmltest.obj"  "mxmltest.res" /Debug
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Debug32.lib(Debug32.obj) : error LNK2001: unresolved external symbol _NtQuerySystemInformation@16
Debug32.lib(Debug32.obj) : error LNK2001: unresolved external symbol _NtQueryObject@20
Debug32.lib(Debug32.obj) : error LNK2001: unresolved external symbol _SymLoadModule64@28
Debug32.lib(Debug32.obj) : error LNK2001: unresolved external symbol _SymGetModuleInfo64@16
Debug32.lib(Debug32.obj) : error LNK2001: unresolved external symbol _SymEnumSymbols@24
Debug32.lib(Debug32.obj) : error LNK2001: unresolved external symbol _SymUnloadModule64@12
mxmltest.exe : fatal error LNK1120: 6 unresolved externals

Error(s) occured.
Equations in Assembly: SmplMath

fearless

Using latest masm32

Prob the szText variable is getting confused with the macro of same name. Just rename szText in to something like szTestText. Ive uploaded a revised version of the project that has that change: https://dl.dropboxusercontent.com/u/17077376/mxmltest.zip

The debug stuff is due to using donkey's vkim like debug32. Ive uploaded a copy of it here: https://dl.dropboxusercontent.com/u/17077376/masm32_donkeys_vkimlike_debug.zip - copy debug32.inc to masm32\include, debug32.lib to masm32\lib and dbgwin.exe to masm32 - that should allow the debug macros to work (PrintDec, PrintStringByAddr etc)

When run the output in dbgwin should be something like:


HSE

The problem with szText was solved changing include order (ie. macros.asm after mxml.inc)

From your post in "Adding items and subitems for listview" I obtained a working debug32.inc.

With link option \Debug now error is:
mxml.lib(gs_report.obj) : fatal error LNK1103: debugging information corrupt; recompile module
but work perfectly without the option.

Interestling, executable send the messages to the RadAsm Output window (instead of opening DbgWin), perhaps I change something a time ago, I don't remenber.

Now I can begin the test  :t
Equations in Assembly: SmplMath

ragdog

#7
Thank you Fearless

I have try other libĀ“s ex: Xmllite from MS ,etc..

If i compile you Radasm2 project works fine ,use i Radasm 3 have i a missing lib
QuoteLNK1104: cannot open file "uuid.lib"

Why this?

My settings

ml /c /coff /Cp "Console.asm"
link /SUBSYSTEM:CONSOLE /RELEASE /VERSION:4.0 /OUT:"Console.exe" "Console.obj"


Your settings

ML.EXE /c /coff /Cp /nologo /I"C:\Masm32\Include" "mxmltest.asm"
LINK.EXE /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /LIBPATH:"C:\Masm32\Lib" /OUT:"mxmltest.exe"


And is a bug in your static mxml.lib  ?

invoke crt_fopen ,chr$ ("Test.xml"), chr$ ("rb");
.if eax!=0
mov hFile,eax
invoke mxmlLoadFile,NULL,eax,MXML_TEXT_CALLBACK
PrintDec eax
.endif


HSE

MXML_NO_CALLBACK

Wrong, perhaps it's a different uuid.lib
Equations in Assembly: SmplMath

fearless

Couldnt get the mxmlLoadfile function to work, but have a demo version using other functions that im putting together. The structures in my original mxml.inc are slightly wrong, so ive updated that and will upload that new version soon.

ragdog

@Hse

Why is this wrong "MXML_NO_CALLBACK"?

testmxml.c
    * Read the file...
    */
    tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);


Quoteand will upload that new version soon.

Nice fearless

HSE

@ragdog
           I though MXML_TEXT_CALLBACK was the problem, but no.
Equations in Assembly: SmplMath

ragdog

No the problem is in the static lib it crash in the Ntdll.

if i use mxmlLoadFile


invoke crt_fopen ,chr$ ("Test.xml"), chr$ ("rb");
.if eax!=0
mov hFile,eax
invoke mxmlLoadFile,NULL,eax,MXML_TEXT_CALLBACK
PrintDec eax
.endif


Address=775E8E19
Message=Access violation when writing to [00000014]



But it same if i use the compiled mxml1.dll  only the testmxml.exe works curious  :icon_exclaim:

fearless

#13
Updated zip with lib and inc: https://www.dropbox.com/s/zc2yvoy587oae87/mxml.zip?dl=0

mxmltree demo: https://www.dropbox.com/s/dc2orxxv5ypmxyo/mxmltree.zip?dl=0

Treeview lib and inc https://github.com/mrfearless/libraries/blob/master/releases/Treeview_x86.zip

Demo using memory mapped file and mxmlLoadString to open xml file. Then some processing looping through xml tree and MS Treeview Control adding elements to Treeview, then xml attributes as child nodes to Treeview. Shows using the structures to access xml tree node (mxml_node_t) and fetch mxml_node_t->node_value->element (mxml_element_t), fetch num_attrs and then loop through attrs array to get attribute name and attribute value.

Few other bits and pieces whilst i was playing around figuring it out.



The child items could be reworked to better reflect actual hierarchy - just easier to add element nodes to root and save node, then add attributes as a child of the node saved, then next item etc etc.

ragdog

Thank you

QuoteDemo using memory mapped file and mxmlLoadString to open xml file
This way works

But not mxmlLoadFile

I think is a problem with config.h by compile a static lib.

Can you share the Visual studio  Project files Visual for this static lib?