Click here to Skip to main content
15,888,143 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I've searched, unfortunately I only found how to do that with C++ or C# - i's pretty different once are object oriented languages.

Can you please point me to the information?

I was simply putting strings:

fputs("<complexType name='DominantColorType” final='#all'>\n",fp);

But I get an "error" at '#'. Anyone know why ?
Posted
Updated 14-Jan-11 6:02am
v2

Does this[^] help? I've not used it, just found it with a quick search.
 
Share this answer
 
Comments
Maxdd 7 14-Jan-11 12:27pm    
helps yes :)

unfortunately I isntalled everyting by the readme (all's ok) but when I compile the test script I get undefined references to phread. Any ideas ?
Thought of:
XML
fputs("<complexType name='DominantColorType" final='#all'>\n",fp);


Take a closer look at DominantColorType"

you probably meant DominantColorType'

For a pure c implementation:
The XML C parser and toolkit of Gnome
[^]

and the there is this Apache Xerces[^] - it's C++ though

Regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Maxdd 7 14-Jan-11 12:26pm    
yes the "pre" solution didnt worked.

yes with the ' it works (sorry my mistake)
Maxdd 7 14-Jan-11 12:26pm    
I'll try to make all xml file with simple fputs and see if Firefox accepts the xml
Espen Harlinn 14-Jan-11 12:44pm    
How about marking the question as answered? :)
fjdiewornncalwe 14-Jan-11 16:05pm    
+5. Same thing jumped out at me right away...
Espen Harlinn 14-Jan-11 16:32pm    
Thanks Marcus!
All you need to write your code by own and first of all you must know XML.

I just can give some hints

You need to define your macros like this
<pre lang="xml">#include <stdio.h>
#include <tchar.h>
#define START_NODE( \
     /*NULL TERMINATED STRING*/NodeName , \
     FilePointer) \
     fprintf( FilePointer , "<%s>\n" , NodeName ) \
#define END_NODE( \
     /*NULL TERMINATED STRING*/NodeName , \
     FilePointer) \
     fprintf( FilePointer , "</%s>\n" , NodeName ) \
int _tmain(int argc, _TCHAR* argv[])
{
    FILE *fp = NULL;     /*i use stdout in place of a file pointer
                         to show the result on concole*/
    START_NODE("t1", stdout);
    END_NODE("t1", stdout);
    getchar();
    return 0;
}



but using these MACROs you can't give attributes to nodes...

This will do if you don't need attributes....

If you want then use functions instead of macros...
 
Share this answer
 
v4
Writing XML with C (or any other programming language) is really simple, you don't need any library (on the other hand reading and parsing XML is a bit more complex).
As someone already noted, your did a mistake in your original XML expression.
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900