Thread: Is anyone using EXPAT? Help needed!

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    42

    Is anyone using EXPAT? Help needed!

    Can anyone point me to a simple example on creating a simple XML document using EXPAT ?

    All I read on EXPAT site is a little to techie for me, I am looking for something clearer.

    As a matter of fact I am trying to learn how to use it by creating a C+Win32 program that gets the system time (hh:mm:ss) every 10 minutes and writes it to a .xml doc like:

    <time>
    <1>XX:XX:XX</1>
    <2>XX:XX:XX</2>
    <3>XX:XX:XX</3>
    ...
    </time>

    I had absolutely no success on creating/writting the xml doc until now, any help will be fantastic, Thanks!

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    is this really related to windows programming? ive never heard of EXPAT.

    im no expert on timing with windows programming, but the way i would do it would be to set a timer and a global counter. ie:

    Code:
    int nCounter;
    FILE *xmlFile;
    
    case WM_CREATE:
    SetTimer(hwnd,ID_TIMER,600000,NULL);
    xmlFile=fopen(...);
    nCounter=0;
    
    case WM_TIMER:
    SYSTEMTIME st;
    GetSystemTime(&st);
    
    fprintf(xmlFile,"<%i>%i:%i:%i</%i>\n",nCounter,st.wHour,st.wMinute,st.wSecond,nCounter);
    
    case WM_CLOSE:
    fclose(xmlFile);
    thats surely a start.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    omg...

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> Can anyone point me to a simple example on creating a simple XML document using EXPAT ?

    From the FAQ...

    >>>
    Where can I get help in using expat?
    Try the xml-dev mailing list (subscribe by mailing to [email protected] with the message subscribe xml-dev). Alternatively try the mailing lists hosted by sourceforge.net.
    <<<

    ...okay! Oh, maybe not...

    >>> All I read on EXPAT site is a little to techie for me, I am looking for something clearer.

    ...ah, so asking a totally obscure question on another site, totally out of context, then popping off at someone that bothered to at least reply to your question...

    >>> omg

    ...as far as can see, Ben's solution answers your "specification".

    Now, what was it you wanted?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    Is anyone using EXPAT? Help needed!
    Can anyone point me to a simple example on creating a simple XML document using EXPAT ?

    All I read on EXPAT site is a little to techie for me, I am looking for something clearer.

    As a matter of fact I am trying to learn how to use it by creating a C+Win32 program that gets the system time (hh:mm:ss) every 10 minutes and writes it to a .xml doc like:

    <time>
    <1>XX:XX:XX</1>
    <2>XX:XX:XX</2>
    <3>XX:XX:XX</3>
    ...
    </time>

    I had absolutely no success on creating/writting the xml doc until now, any help will be fantastic, Thanks!

  6. #6
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    you know, im really insulted by that post templario. first of all i go out of my way to try and help you. you brush that aside without even explaining what was wrong with it, and then, now this is the good part, you actually have the nerve to bump your post. On top of that, you even bumped with the exact same original post.

    if you want people to help you on this board, try learning some manners first.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    Ok, sorry. I´m having a very bad week filled with very serious problems. And I know no one got nothing to do with that. So I apologize.

    You know how a job is: I can´t just choose to create a xml file using fprintf or any other std stuff just because I want too. They want to use EXPAT and I have to deal with it if I want to keep my job. And time is running low.

    Again, no one has anything to do with it. So I thank you for your reply and the time you wasted on writting it, really.

    Now, if anyone has ever used EXPAT succesfully to create a xml file, please post an example or send me a message.

    Thanks.

  8. #8
    fou
    Guest
    Expat is a read only xml parser.

    If you only want to do something as simple as you suggest you can just put it into a file by hand as suggested.

    Otherwise you will need an editing capable xml parser, preferably with a dom implementation.
    You can find a list here:
    http://www-106.ibm.com/developerwork...y/x-ctlbx.html

    If you are only targeting windows I would recommend the msxml implementation. Otherwise a good portable C parser can be found here (use it with the gdome module to prodvide DOM support):
    www.xmlsoft.org

    Have Fun!

    P.S If you're fired because you can't create a XML document with a read only parser that would seem a bit harsh!

    P.P.S That is quite a weird XML schema you are using.
    A better one would be:
    <ENTRY id="1">XX:XX:XX</ENTRY>
    <ENTRY id="2">XX:XX:XX</ENTRY>
    This would enable you to retrieve all the entry elements. Your example consists of a series of unrelated elements and while may look logical to a human is not logical to a computer.

  9. #9
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    Hey fou, thanks a lot I was living hell trying to find a way to make expat generate the xml, and i could find no documentation on that

    I had to print your post on this thread and show it to my boss to convince him that it was impossible to use expat that way...

    Now i got a month to decide what i´m gonna use and present a beta, thats is amazing

    I´m gonna research more on all the options you presented me. The target is Windows, i am thinking on using msxml, i´ll give it some hours of study now.

    Anyway, i can´t thank you enough!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM