|
If you want to add PI node ( stuff), then you should use XDoc instead of XNode.
XDoc has one root element node. you can access with using XDoc::GetRoot().
and other node like PI is child of XDoc.
XDoc is equal with XNode. but XDoc has another function, it is container of PI. (it's same to MSXML )
so, you can do like below.
XDoc doc;
// make
XNode* pPI = new XNode;
pPI->name = "xml";
pPI->type = XNODE_PI;
pPI->CreateAttr( "version", "1.0" );
doc.AppendChild( pPI );
// make root element node
XNode* pRoot = new XNode;
// you might know how to build childs of pRoot.
// plz check my previous answer.
doc.AppendChild( pRoot );
AfxMessageBox( doc.GetXML() );
and, this time also, i didn't compile upper code. just type on online, plz don't blame some errors..
Thanks for using.
ps. you can get string with GetXML() member function of XDoc or XNode.
once you get the string of XML, then u can save to file by using fopen/fwrite stuff
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Can xmlite Load xml files ??such as temp.xml??
|
|
|
|
|
you can load xml from file like below example.
int LoadFromFile(char* fpath, char* buf)
{
FILE* fp;
fp = fopen(fpath, "rt");
if( fp == NULL)
return 0;
fread(buf, 1, 1000, fp );
fclose(fp);
return 1;
}
void CTestXMLiteDlg::OnButton13()
{
// TODO: Add your control notification handler code here
char buf1[1000];
char buf2[1000];
XNode node1;
XNode node2;
if( LoadFromFile("a.xml", buf1) == 0 )
{
AfxMessageBox("no file a.xml");
return;
}
node1.Load( buf1 );
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
"We are currently using XMLite in our MavBridge product,
which converts scanner data files between various formats (many of which
are XML). The code has worked very well, and has been very easy to use."
MAVRO IMAGING LLC
www.MavroImaging.com
They sended thanks mail to me.
I hope xmlite can help with their work.
I will add to reference section.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
I've to read XML Data from an URL using C++. How can I do this?
|
|
|
|
|
you can download from url like below: (MFC version, but you can easily find, Win32 version, or socket version on googling)
just modify that function to save string.
BOOL SaveImage(LPCTSTR szImgPath)
{
CInternetSession is;
CInternetFile* pif = NULL;
HANDLE hFile = NULL;
pif = (CInternetFile*)is.Openurl(szImgPath, 1, INTERNET_FLAG_TRANSFER_BINARY);
if ( pif == NULL )
return FALSE;
CHAR szLocalFile[255];
wsprintf(szLocalFile, "C:\\%s", pif->GetFileName());
hFile = CreateFile(szLocalFile, GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if ( hFile == INVALID_HANDLE_VALUE )
{
pif->Close();
is.Close();
return FALSE;
}
while(1)
{
INT nRead = 0;
DWORD dwWritten = 0;
CHAR szBuffer[255];
nRead = pif->Read(szBuffer, 255);
if ( nRead == 0 )
break;
WriteFile(hFile, szBuffer, nRead, &dwWritten, NULL);
}
CloseHandle(hFile);
pif->Close();
is.Close();
return TRUE;
}
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
How can i read a specific file with XMLite?
I am new with C++ and i have to do this as soon as possible! please help
|
|
|
|
|
just you can read file to string variable. and load that xml string to xmlite.
char sXml[1000];
FILE* fp = fopen("some.xml", "rt");
long filesize = ftell(fp);
fread(sXml, sizeof(char), filesize, fp);
then you have xml string. and load to xmlite
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Hello,
I would like to know the memory constraint of this parser on mobile platform (planning to use for WM).
The avg size of the XML file to be fed to the parser would be 50KB.
Any suggestions or inputs would be highly appreciated.
Thnkz,
Zoom
|
|
|
|
|
You might be better off with CMarkup, we found this much quicker to load in a large XML file as it only points to elements, attributes in the file rather than copying them. So uses little additional memory to the size of the file itself.
www.firstobject.com/xmleasy.htm
|
|
|
|
|
Just wondered why XMLite impliments the CDATA in the way it does, (a child of a child) is this a normal implementation.
I have the XML line
"<Parameter><![CDATA[Window 1]]></Parameter>"
and in order to get the value of the Parameter, I have to do the following:
pAttributeChild = GetChild("Parameter");
strValue = pAttributeChild->GetChildValue("#CDATA");
I thought I would be able to do:
strValue = pAttributeChild->GetChildValue("Parameter");
as I do for all values that are not encapsulated in the CDATA.
Thanks
Ian
|
|
|
|
|
Yes. I made that node name with "#CDATA".
you can see that function on LoadCDATA.
LPTSTR xml = (LPTSTR)pszXml;
xml += sizeof(szXMLCDATAOpen)-1;
LPXNode node = new XNode;
node->parent = this;
node->doc = doc;
node->type = XNODE_CDATA;
node->name = _T("#CDATA");
_SetString( xml, end, &node->value, FALSE );
par->childs.push_back( node );
If you want, then modify that code for your purpose. and if I have some mistake or miss-standard. then just modify and share that. thanks.
but i wonder, if 'Parameter' node have CDATA and value text like below:
"<Parameter>Value of Parameter<![CDATA[Window 1]]></Parameter>"
then which one (Value of Parameter and CDATA stuff) can be selected for Parameter's value?
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
We have chosen to stick with your current implementation for now.
Thanks
Ian
|
|
|
|
|
Anybody has this working on Visual Studio 2005?
|
|
|
|
|
XNodes::iterator _tagXMLNode::GetChildIterator( LPXNode node )<br />
{<br />
XNodes::iterator it = childs.begin();<br />
for( ; it != childs.end() ; ++(it) )<br />
{<br />
if( *it == node )<br />
return it;<br />
}<br />
return NULL; <br />
}<br />
|
|
|
|
|
you can find that fix in other's reply.
Thank you all. No one know oneself all. My idea from you, book, all others. already we are shared brains.
|
|
|
|
|
Good work. Yet I realize that this isn't a standard-compliant code. XMLite.cpp at line 330 throws me an error: 'i' undeclared identified. You have the following code:
for( int i = 0 ; i < childs.size(); i ++)
{
...
}
childs.clear();
for( i = 0 ; i < attrs.size(); i ++)
{
...
}
While compiling it with VC8 it throws me 7 errors and 17 warnings.
Regards.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
You can download this http://download.svetla.org/download/XMLite.ZIP for your project. I´m using it for unicode too. I recommend substitute ->name for ->GetName().
Regards.
Jaroslav Nusl
www.svetla.org
|
|
|
|
|
My project is based and compiled with Unicode (VC2005). When I compile this excellent code I get some errors because of that (for example the use of strchr). Can someone know where to get a Unicode version.
Thanks,
Yossi.
|
|
|
|
|
Hi Yossi
I reached that it works for me with Unicode, VC2005.
I had to recreate a project as Unicode, and make some corrections...
Most important change types are listed:
* '<' -> _T('<'), " ?>" -> _T(" ?>"), etc in all similar cases
* sizeof(szXMLCDATAOpen) -> sizeof(szXMLCDATAOpen)/sizeof(TCHAR), and similar
* memcpy( pss, psz, len); ->
#ifdef _UNICODE
memcpy( pss, psz, 2*len);
#else
memcpy( pss, psz, len);
#endif
* if( strchr( pszchs, *psz ) ) return (LPTSTR)psz; ->
#ifdef _UNICODE
if( wcschr( pszchs, *psz ) ) return (LPTSTR)psz;
#else
if( strchr( pszchs, *psz ) ) return (LPTSTR)psz;
#endif
* std::ostringstream os; ->
#ifdef _UNICODE
std::wostringstream os;
#else
std::ostringstream os;
#endif
There are also many changes to address warnings.
If you like, I could send to you my version, or put it in some public place, please instruct.
AlexandreN
|
|
|
|
|
If you would care to share your Unicode version that'd be great ! Judging by the number of errors I get it sounds quite a big task, especially with regard to std::string which appears to be 'char' based regardless of whether you are compiling UNICODE or not (or have I missed something) ???
TTFN,
Jon
|
|
|
|
|
I would gladly share, if somebody explained me the best practice how to share.
Alexandre
|
|
|
|
|
Hi Alexandre,
I'm not sure best way to share. If you get stuck I can temporarily host them on my website so othres can download them, at least until a better solution is found.
TTFN,
Jon
PS : I tried to reply to your email address but it bounced ....
|
|
|
|
|
Jon,
I am looking for Unicode version of XMLlite. Hi can you post Unicode version of XMLLite ?
|
|
|
|
|
Love xmlite so far but ran into a problem today trying to parse the document.xml file found in the .docx zip file (Word2007 document file). In the .xml file, there are 12 tags with the name "w:p". After parsing, xmlite shows only one w:p tag. I am using the xmlite download from Creative Commons.
I am a complete novice at xml and xmlite, so I may be committing some obviously stupid mistake. However, everything I have parsed prior to this file has acted as expected and thus I don't know why this doesn't act the same. Any ideas?
I have attached the document.xml file below.
thanks for any help you might provide.
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns ="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"><w:body><w:p w:rsidr="001671DB" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:pstyle w:val="Heading1"><w:r><w:t>Heading 1<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:r><w:t>Heading 1 normal text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:rpr><w:b><w:r w:rsidrpr="00265A14"><w:rpr><w:b><w:t>Bold Text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:rpr><w:i><w:r w:rsidrpr="00265A14"><w:rpr><w:i><w:t>Italics Text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:rpr><w:b><w:i><w:r w:rsidrpr="00265A14"><w:rpr><w:b><w:i><w:t>Bold Italics Text<w:p w:rsidr="00A424D9" w:rsidrpr="00A424D9" w:rsidrdefault="00A424D9" w:rsidp="00265A14"><w:r><w:t xml:space="preserve">This is a long run of normal text to show how multiple lines are treated in a single run of really long <w:r w:rsidr="009228BE"><w:t xml:space="preserve">skinny tall short fat light <w:r><w:t>long text.<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:pstyle w:val="Heading2"><w:r><w:t>Heading2<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:r><w:t>Heading2 normal text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:ppr><w:pstyle w:val="Heading3"><w:r><w:t>Heading 3<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:r><w:t>Heading 3 normal text<w:p w:rsidr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:p w:rsidr="00265A14" w:rsidrpr="00265A14" w:rsidrdefault="00265A14" w:rsidp="00265A14"><w:sectpr w:rsidr="00265A14" w:rsidrpr="00265A14" w:rsidsect="001671DB"><w:pgsz w:w="12240" w:h="15840"><w:pgmar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"><w:cols w:space="720"><w:docgrid w:linepitch="360">
|
|
|
|