Home > Software engineering >  For a book about C access XML?
For a book about C access XML?

Time:11-21

Who know the c + + to access XML book? Told that just a little, want to learn the XML can find a book, have know told the title,
Or access XML approach can also be learning c + +, thanks.

CodePudding user response:

tinyxml

CodePudding user response:

What do you mean to parse the XML file? DOM MSXML, CMarkup

CodePudding user response:

Don't have to go to special reading, speaking, reading and writing XML, try to baidu search: pugixml tutorial

CodePudding user response:

Still no, have you ever know?

CodePudding user response:

QT also can,

CodePudding user response:

reference 5 floor zyrr159487 reply:
QT also can,


I don't want to so complicated, simple point

CodePudding user response:

Repidxml this also need to book, you just to search

CodePudding user response:

Where has the resources? Posted to see

CodePudding user response:

Used to write their own reading and writing XML configuration file:
 cstrings: : ReadSingleNodeXml (cstrings SEC, cstrings key) 
{
CoInitialize (NULL);
BSTR STRV=L "";
Cstrings strdir=_T (" ");
Cstrings selnodecstr=_T (" ");
CComPtr SpXmldoc;
HRESULT hr=spXmldoc. CoCreateInstance (L "MSXML2. DOMDocument. 6.0");
If (SUCCEEDED (hr))
{
VARIANT_BOOL isSuccessFul;

GetAppPath (strdir);
Strdir=strdir + _T (" \ \ \ Program \ \ aConfig XML ");
CComVariant varXmlFile (strdir);

SpXmldoc - & gt; Put_async (VARIANT_FALSE);
Retrieves the hr=spXmldoc - & gt; Load (varXmlFile, & amp; IsSuccessFul);
If (isSuccessFul==VARIANT_TRUE)
{
CComBSTR bstrXml;
CComPtr SpRoot=NULL;
Hr=spXmldoc - & gt; Get_documentElement (& amp; SpRoot);
SpRoot - & gt; Get_xml (& amp; BstrXml);


CComPtr SpTheNode=NULL;
Selnodecstr=_T ("/aConfig/") + SEC + _T ("/") + key;

SpRoot - & gt; SelectSingleNode (: : SysAllocString (selnodecstr), & amp; SpTheNode);
If (spTheNode!=NULL)//node
was not found{
SpTheNode - & gt; Get_text (& amp; STRV);
}
SpRoot. Release ();
BstrXml. Empty ();
}
VarXmlFile. ClearToZero ();
}
SpXmldoc. Release ();
CoUninitialize ();
Return (cstrings) STRV;
}
Int: : WriteSingleNodeXml (cstrings SEC, cstrings key, cstrings val)
{
CoInitialize (NULL);
Int result=1;
Cstrings strdir=_T (" ");
Cstrings selnodecstr=_T (" ");
CComPtr SpXmldoc;
HRESULT hr=spXmldoc. CoCreateInstance (L "MSXML2. DOMDocument. 6.0");
If (SUCCEEDED (hr))
{
VARIANT_BOOL isSuccessFul;

GetAppPath (strdir);
Strdir=strdir + _T (" \ \ \ Program \ \ aConfig XML ");
CComVariant varXmlFile (strdir);

SpXmldoc - & gt; Put_async (VARIANT_FALSE);
Retrieves the hr=spXmldoc - & gt; Load (varXmlFile, & amp; IsSuccessFul);
If (isSuccessFul==VARIANT_TRUE)
{
CComBSTR bstrXml;
CComPtr SpRoot=NULL;
CComPtr SpTheElem=NULL;
CComPtr SpNewNode=NULL;
CComPtr SpTheNode=NULL;
Hr=spXmldoc - & gt; Get_documentElement (& amp; SpRoot);
SpRoot - & gt; Get_xml (& amp; BstrXml);


Selnodecstr=_T ("/aConfig/") + SEC + _T ("/") + key;

SpRoot - & gt; SelectSingleNode (: : SysAllocString (selnodecstr), & amp; SpTheNode);
If (spTheNode!=NULL)//node
was not found{
SpTheNode - & gt; Put_text (: : SysAllocString (val));
SpXmldoc - & gt; Save (varXmlFile);//save the XML,
Result=0;
}
The else
{
SpXmldoc - & gt; The createElement method (: : SysAllocString (key), & amp; SpTheElem);
SpTheElem - & gt; Put_text (: : SysAllocString (val));

SpRoot - & gt; SelectSingleNode (: : SysAllocString (_T ("/SaejongConfig/") + SEC), & amp; SpTheNode);
SpTheNode - & gt; The appendChild (spTheElem, & amp; SpNewNode);

SpXmldoc - & gt; Save (varXmlFile);//save the XML,
Result=0;
}

SpRoot. Release ();
BstrXml. Empty ();
}
VarXmlFile. ClearToZero ();
}
SpXmldoc. Release ();
CoUninitialize ();

return result;
}
  • Related