Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to extract variables from between html tags?

How to extract variables from between html tags?

Scheduled Pinned Locked Moved C / C++ / MFC
htmldata-structureshelptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    purpleturple
    wrote on last edited by
    #1

    Suppose something like this: [code] <span class="gugugug">1</span> <span class="krakaka">enchanted</span><span class="gagaga">chocolate bar</span> <span class="gugugug">2</span> <span class="krakaka">very remarkable</span><span class="gagaga">flavored cookies</span> <span class="gugugug">3</span> <span class="krakaka">fascinating</span><span class="gagaga">strawberries</span> (...) <span class="gugugug">254</span> <span class="krakaka">amazing</span><span class="gagaga">pineapples</span> (...) [/code] And it goes on. I need to extract the numbers and words between the <span> and </span> tags ("1", "enchanted", "chocolate bar", "2", "very remarkable", and so on) and put it in a bidimensional array. But what piece of code do I need in order to extract from between the tags? I'm imagining it's something easy, but I'm completely new, whereas you guys are extremely good, so please help. :)

    J 1 Reply Last reply
    0
    • P purpleturple

      Suppose something like this: [code] <span class="gugugug">1</span> <span class="krakaka">enchanted</span><span class="gagaga">chocolate bar</span> <span class="gugugug">2</span> <span class="krakaka">very remarkable</span><span class="gagaga">flavored cookies</span> <span class="gugugug">3</span> <span class="krakaka">fascinating</span><span class="gagaga">strawberries</span> (...) <span class="gugugug">254</span> <span class="krakaka">amazing</span><span class="gagaga">pineapples</span> (...) [/code] And it goes on. I need to extract the numbers and words between the <span> and </span> tags ("1", "enchanted", "chocolate bar", "2", "very remarkable", and so on) and put it in a bidimensional array. But what piece of code do I need in order to extract from between the tags? I'm imagining it's something easy, but I'm completely new, whereas you guys are extremely good, so please help. :)

      J Offline
      J Offline
      Jeff Archer
      wrote on last edited by
      #2

      Have you checked out MSXML? It will parse the xml and let you deal with through an object model.

      B PJ ArendsP 2 Replies Last reply
      0
      • J Jeff Archer

        Have you checked out MSXML? It will parse the xml and let you deal with through an object model.

        B Offline
        B Offline
        Bhushan1980
        wrote on last edited by
        #3

        I do not know what language you are using, but since it is posted under C/C++/MFC tab, I assume that it is....Pardon me, I just came here through a google search so I found the post under C/C++/MFC tab. Now as said by the previous reply u got, you can use MSXML. Or if you have an option of using .NET (C# or VB.NET), then you can just make use of HTMLDocument, HTMLElement, HTMLElementCollection classes, and get the tags and the info inside them. Then use .NET interop to bring them to native C++. Or you can just use /clr option that VC++ compiler provides u and write managed code in C++ application as well...Other than that, I am also waiting for a good method or previous code that has been posted on the net to do it. I had hoped to find some information about this on MSDN, but in vain. Eventually, I hope something in this regards is posted some where... Bhushan

        J 1 Reply Last reply
        0
        • B Bhushan1980

          I do not know what language you are using, but since it is posted under C/C++/MFC tab, I assume that it is....Pardon me, I just came here through a google search so I found the post under C/C++/MFC tab. Now as said by the previous reply u got, you can use MSXML. Or if you have an option of using .NET (C# or VB.NET), then you can just make use of HTMLDocument, HTMLElement, HTMLElementCollection classes, and get the tags and the info inside them. Then use .NET interop to bring them to native C++. Or you can just use /clr option that VC++ compiler provides u and write managed code in C++ application as well...Other than that, I am also waiting for a good method or previous code that has been posted on the net to do it. I had hoped to find some information about this on MSDN, but in vain. Eventually, I hope something in this regards is posted some where... Bhushan

          J Offline
          J Offline
          Jeff Archer
          wrote on last edited by
          #4

          In this message board the correct assumption is native C/C++. There are seperate message boards for .net, C#, and managed C++. So the best answer is MSXML and there are plenty of examples available by googling MSXML Examples.

          1 Reply Last reply
          0
          • J Jeff Archer

            Have you checked out MSXML? It will parse the xml and let you deal with through an object model.

            PJ ArendsP Offline
            PJ ArendsP Offline
            PJ Arends
            wrote on last edited by
            #5

            There is also this[^] and I am sure many more like it. MSXML is not the only option.


            You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

            Within you lies the power for good; Use it!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups