1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

XML Parsing Using libXML2

Discussion in 'C' started by debapriya.patra, Mar 25, 2009.

  1. debapriya.patra

    debapriya.patra New Member

    Joined:
    Mar 25, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Hi All,

    I am really new to C++ language. I wanted to write a small program in C++ using libxml2.
    Can anyone help me in this.I am really helpless..i mean i am unable to proceed, not even getting any help on this.

    My requirement is to parse a string content using libxml2...that string content is nothing but the xml content as string.

    thnaks in advance

    Regards,
    Deba
     
  2. alwaysLearning

    alwaysLearning New Member

    Joined:
    Mar 27, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    what type of help you are asking?
    There are lots of online tutorial about persing xml.
    First link found in google search for libxml2 is quite usefull.

    http://www.xmlsoft.org/tutorial/index.html

    Regards,

    Shaikat
     
  3. debapriya.patra

    debapriya.patra New Member

    Joined:
    Mar 25, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Hi ,

    Sorry to say that i am really confused with that site and whtever example is der..
    I really wanted something which i am not getting der....


    If you can help me on this then it will be good.
    Like i wanted to parse one XML string and get the values from the nodes using libxml2.

    Really i need help...Frankly speaking i don't know anything about C++ .and the biggest problem is i don't how to use third party library like "libxml2"..I used to put the jars in our class path for java but here how do i do that....


    So hope anyone can help me in all this problems..


    Regards,
    Deba
     
  4. alwaysLearning

    alwaysLearning New Member

    Joined:
    Mar 27, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Hi Deba,

    First make sure you have installed libxml2.
    you should see a libxl2.so file ( so is a library file in linux like jar) in /usr/lib

    then while compile do this:

    g++ test.cpp -o test -lxml2

    notice the -lxml2 which includes the library while compiling.


    Go step by step.
    First try to create an xml doc.
    Then try to create element for xml doc.
    Then try to add attribute to xml doc.
    Then dump it in a buffer.
    Then try to parse that buffer.
    Up to this:
    Follow this thread: http://www.go4expert.com/showthread.php?t=16761

    Now when you are done, let me know i will try to give you a code for persing.
     
  5. debapriya.patra

    debapriya.patra New Member

    Joined:
    Mar 25, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Hi Shaikat,

    Many Many thanks for ur response..I am really very very happy ..
    Anyway i think u told me for the Linux environment but i am working only in windows and our development is on windows only.And i am using VC++ 6 and eclipse also for development.

    And I have downloaded below things:
    1)libxml2-2.7.3.win32.zip
    2)iconv-1.9.2.win32.zip
    3)libxmlsec-1.2.11+.win32.zip
    4)libxslt-1.1.24.win32.zip

    Because as per the instruction i need all these supported libraries for to work with libxml2 so i have downloaded.And according to the information i unziped all this and copied all the .lib files and .exe files from these folders into one folder and set the path to that folder .


    And Now i wanted to know whatever i did is correct or wrong for windows environment.IF not correct then wht i need to do.
    And another thing is i dont want to create the xml i have one string which is nothing but xml content.I just wanted to parse that string xml and get the values from the nodes .


    Please guide me..i really need ur help to do this.


    Regards
    Deba
     
  6. debapriya.patra

    debapriya.patra New Member

    Joined:
    Mar 25, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Sorry one mistake i did in my previous reply..instead of writing .dll and .exe , i wrote .lib and .exe

    sorry for that....
     
  7. alwaysLearning

    alwaysLearning New Member

    Joined:
    Mar 27, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I am mainly a linux guy, so i wont be that helpful for windows.

    but here is a good link to include dll in a vc++ 6

    http://www.codeproject.com/KB/DLL/XDllPt1.aspx

    the general examples which i gave on the other thread should also work fine under windows.
     
  8. debapriya.patra

    debapriya.patra New Member

    Joined:
    Mar 25, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    Thanks a lot for that link.That link is really help full for me. And i am able to link the libraries which i have downloaded.

    Even though you are working on Linux only difference will be the way you are writing the code and the way you are compiling the code.

    But you can give me a sample code using libxml2 which will parse an xml string. I mean the String is nothing but the xml content.

    And i will try that code in windows and see the result...


    Please help and on this.


    Regards
    Deba
     

Share This Page