-
October 9th, 2014, 02:58 AM
#1
XML Parsing
In VC++ is there any inbuilt class for storying values inside an XML File, without using CLI?
-
October 9th, 2014, 03:34 AM
#2
-
October 9th, 2014, 04:19 AM
#3
Re: XML Parsing
 Originally Posted by maverick786us
In VC++ is there any inbuilt class for storying values inside an XML File, without using CLI?
No, any inbuilt one does not exist. You have to use some library to deal with XML. (In fact this is the way C/C++ deal with anything else.)
Full-fledged lib from MS: MSXML
Best regards,
Igor
-
October 9th, 2014, 08:11 AM
#4
Re: XML Parsing
Probably, the word "inbuilt" used here is not very clear for me.
So let me try do detail a little bit by quoting from MSDN:
The XmlLite runtime file, Xmllite.dll, is integrated into the following operating systems and products:
- Windows 8
- Windows Server 2008 R2
- Windows 7.
- Windows Server 2008
- Windows Vista
- Windows XP with Service Pack 3 or later.
- Windows Server 2003 with Service Pack 2 or later.
- Microsoft Internet Explorer 7 and later.
To build applications with XmlLite, you must install the XmlLite development files, Xmllite.lib and Xmllite.h.
[...]they are only provided in the Windows SDK for Vista.
[...]You do not have to install the entire Windows SDK to get Xmllite.lib and Xmllite.h. To get Xmllite.lib and Xmllite.h...
All details can be found here: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
Indeed MSXML parser may be a better option, but can scare the C++ programmers which don't know too much about using COM components.
Dealing with Xmllite is easier and good enough in many cases.
Last edited by ovidiucucu; October 9th, 2014 at 08:15 AM.
Reason: typo
-
October 10th, 2014, 06:51 AM
#5
Re: XML Parsing
there are other libraries as well.
There's a basic xml lib in boost
if your expected xml is simple enough, you can even write your own parser in a couple hundred lines of code (been there, done that), but things can quite quickly get difficult if you need to deal with namespaces, different character encoding, DTD's, Entities, if you need to worry about formatting, or need to handle special features like CData, and/or if you need to care about valid, yet awkward/unusual xml.
the thing you'd need to worry about first is if you want a SAX/Streaming approach, or a DOM/load everything type approach.
with SAX, the xml is read and your app is called into via a callback mechanism each time a tag is found, the xml is never loaded entirely, and you only see each tag once.
with DOM, the xml is loaded into memory, and you can then do queries (usually XPath, but some libs have their own built in method/script) to extract the data you need.
Both approaches have benefits and disadvantages.
-
October 15th, 2014, 05:29 PM
#6
Re: XML Parsing
I have experimented with a number of XML parsers and have become sold on XmlLite.
Pretty simple to use.
Code:
#include <xmllite.h>
#pragma comment (lib, "xmllite.lib")
class MyXmlParser
{
//
IStream *pFileStream;
IXmlReader *pReader;
XmlNodeType nodeType;
IStream *pOutFileStream;
IXmlWriter *pWriter;
//
};
The examples cited above are very good.
mpliam
-
October 16th, 2014, 07:54 AM
#7
Re: XML Parsing
 Originally Posted by Mike Pliam
I have experimented with a number of XML parsers and have become sold on XmlLite.
Pretty simple to use.
Code:
#include <xmllite.h>
#pragma comment (lib, "xmllite.lib")
class MyXmlParser
{
//
IStream *pFileStream;
IXmlReader *pReader;
XmlNodeType nodeType;
IStream *pOutFileStream;
IXmlWriter *pWriter;
//
};
The examples cited above are very good.
Is this the best? What I am looking for is a light weight class that can be easily exported in a Win 32 DLL
-
October 16th, 2014, 08:24 AM
#8
Re: XML Parsing
 Originally Posted by maverick786us
Is this the best? What I am looking for is a light weight class that can be easily exported in a Win 32 DLL
Who knows what could be "the best" for you? 
However, it is pretty easy to use. Just try the XmlLite Samples:
Read an XML Document using XmlLite
Write an XML Document using XmlLite
Victor Nijegorodov
-
October 16th, 2014, 02:23 PM
#9
Re: XML Parsing
 Originally Posted by maverick786us
Is this the best? What I am looking for is a light weight class that can be easily exported in a Win 32 DLL
I wander Are You Really Serious? Best? Lightweight? Easy? YES! MSXML is really the best, ligtweight and easy to use. For me. And I don't care if it does the same for you. Does this fact matter anyhow for YOU? Please stop bogging us with irrelevant questions of the kind. Ans let's get technical, for the sake of all of us.
Best regards,
Igor
-
October 17th, 2014, 12:58 AM
#10
Re: XML Parsing
 Originally Posted by Igor Vartanov
I wander Are You Really Serious? Best? Lightweight? Easy? YES! MSXML is really the best, ligtweight and easy to use. For me. And I don't care if it does the same for you. Does this fact matter anyhow for YOU? Please stop bogging us with irrelevant questions of the kind. Ans let's get technical, for the sake of all of us.
I mean there are so many 3rd party SDKs and classes for XML parsing. By light weight I mean that it should have minimal dependency DLLs and classes, when I deploy it on my client's PC. I agree that the solutions that you have provided are all excellent examples
-
October 17th, 2014, 02:43 AM
#11
Re: XML Parsing
 Originally Posted by maverick786us
I mean there are so many 3rd party SDKs and classes for XML parsing. By light weight I mean that it should have minimal dependency DLLs and classes, when I deploy it on my client's PC.
Then I'd use one of the MSFT product.
Victor Nijegorodov
-
November 14th, 2014, 06:38 AM
#12
Re: XML Parsing
XML Light is something that is desinged for Window 8.1 and above. Can someone show me a simple code snippt where I can save these values in an XML File?
Code:
Encryption enable = Yes
Color Code = 0x66655
Display Frames = Yes
Highlighted spam sites = No
Context Sensitive warning = No
HW ID = XXXXX
Status = Yes
Product Serial Number = EEFSE-WEXXE-WVRX-FRDXD
Operating System Version = Windows 8.1
Last edited by maverick786us; November 14th, 2014 at 07:12 AM.
-
November 14th, 2014, 06:47 AM
#13
-
November 14th, 2014, 07:15 AM
#14
Re: XML Parsing
 Originally Posted by VictorN
Really? 
Then how could I use it about two years back in my Windows XP SP3 computer?
Please, have a look at the post#4.
Sorry about that. I don't know if this XML Light automatically decides a format. But can you demonstrate with code sample, on how I can save the below values in XML file?
Code:
Encryption enable = Yes
Color Code = 0x66655
Display Frames = Yes
Highlighted spam sites = No
Context Sensitive warning = No
HW ID = XXXXX
Status = Yes
Product Serial Number = EEFSE-WEXXE-WVRX-FRDXD
Operating System Version = Windows 8.1
-
November 14th, 2014, 08:12 AM
#15
Re: XML Parsing
Did you try the Microsoft sample code for writing?
https://code.msdn.microsoft.com/XmlL...hId=1720047283
There is a code and there is a XML-file example.
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|