Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Import/Export registry sections as XML

, 21 Jan 2003
Export registry sections as XML to simplify registry diffs
registryasxml_demo.zip
ReleaseMFCdll
registryasxml.exe
Release
registryasxml.exe
registryasxml_src.zip
registryxml.dsp
registryxml.dsw
res
Icon_Anchor.jpg
Icon_Form.jpg
Icon_Frame.jpg
Icon_Media.jpg
Icon_Root.jpg
ImageList.bmp
ImageList256.bmp
registryxml.ico
RegistryxmlDoc.ico
TocImageList.bmp
Toolbar.bmp
registryxml.opt
registryxml.plg
registryxml.suo
registryasxml__demo.zip
registryasxml.exe
registryasxml.exe
registryasxml__src.zip
registryxml.dsp
registryxml.dsw
Icon_Anchor.jpg
Icon_Form.jpg
Icon_Frame.jpg
Icon_Media.jpg
Icon_Root.jpg
ImageList.bmp
ImageList256.bmp
registryxml.ico
RegistryxmlDoc.ico
TocImageList.bmp
Toolbar.bmp


#pragma once

class CFile; // forward declaration


//// xmlreader //////////////////////////////////////////////////////////////////////
//
//
//


enum NODETYPE
{
	NODETYPE_NA = 0,
	NODETYPE_BEGINELEMENT = 1,
	NODETYPE_ENDELEMENT = 2,
	NODETYPE_ATTRIB = 3,
	NODETYPE_CONTENT = 4,
	NODETYPE_PI = 5,
	NODETYPE_COMMENT = 6,
	NODETYPE_CDATA = 7
};

#define IDS_EMPTYELEMENTNAME	"Empty element name"
#define IDS_BADBEGINNODESYMBOL "Bad '<' symbol"
#define IDS_NOBEGINNODESYMBOLINEOL "'<' symbol not allowed at the end of a line"
#define IDS_GENERICSYNTAXERROR	"Syntax error"
#define IDS_MISSINGATTRIBNAME	"Missing attribute name before '='"
#define IDS_MISSINGEQUALSYMBOL  "Missing '=' after attribute name"
#define IDS_NOEQUALSYMBOLINEOL "There should not be a '=' symbol at the end of a line"
#define IDS_BADATTRIBUTEVALUESYNTAX "There should not be a quote char at the end of a line"



class XmlReader
{
	// Members
	//
protected:
	CStdioFile	m_File; // general file members
	BOOL		m_bFileOpen;
	CString		m_szFilename;
	BOOL		m_bShowMsgBoxOnError; // TRUE if message boxes are allowed to display while parsing
	CString		m_szLastError; // filled with error description if ParseContent() returns FALSE

	//
	CString		m_szContent; // internal use : parser buffer
	long		m_nCursor, m_nbLines; // internal cursors (horizontal and vertical directions)
	NODETYPE	m_nCurNodeType; // returns where is the parser on at the moment
	CString		m_szCurNodeName, m_szCurNodeContent; // returns the current node value, and the current node content value
	CString		m_szCurAttribName, m_szCurAttribValue; // returns the current attrib name/value pair
	CString		m_szCurPInstruction; // returns the current PInstruction (for instance ?xml, !DOCTYPE, ...)
	BOOL		m_bCurInsideComment; // TRUE if the parser is inside a comment ( <!-- ... -->)
	BOOL		m_bCurInsideCDATA; // TRUE if hte parser is inside a CDATA secrtion ( <![CDATA[[ ... ]]> )
	BOOL		m_bCurInsideNode; // TRUE if the parser is inside a node begin tag
	BOOL		m_bCurInsideAttrib; // TRUE if m_szCurAttribName is valid and m_szCurAttribValue is pending
	BOOL		m_bCurInsideContent; // TRUE if the parser is inside content

	// Constructor
public:
	XmlReader();
	virtual ~XmlReader();

	// Accessors
public:
	CString &GetFilename() { return m_szFilename; } // file related
	BOOL MustBeClosed() { return m_bFileOpen; }

	void ShowMsgBoxOnError(BOOL bShow=TRUE);
	

	NODETYPE GetNodeType(); // DOM related
	void GetNodeName(/*out*/CString &szName);
	void GetAttrib(/*out*/CString &szName, /*out*/CString &szValue);
	void GetNodeContent(/*out*/CString &szContent);

	long GetCurrentLine();
	void GetPInstruction(/*out*/CString &szName);

	void GetLastError(/*out*/CString &szErrorDescription); // if any

	// Methods
public:
	void Init(); // file related
	BOOL Open(CString &szFilename);
	virtual BOOL ReadString();
	BOOL Close();

	// Internal
	//
protected:
	BOOL ParseContent();

};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Addicted to reverse engineering. At work, I am developing business intelligence software in a team of smart people (independent software vendor).
 
Need a fast Excel generation component? Try xlsgen.
 

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141030.1 | Last Updated 22 Jan 2003
Article Copyright 2002 by Stephane Rodriguez.
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid