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. Web Development
  3. ASP.NET
  4. Find highest XML value in <p x="-0.979248" y="-0.00141319" />

Find highest XML value in <p x="-0.979248" y="-0.00141319" />

Scheduled Pinned Locked Moved ASP.NET
xml
3 Posts 2 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.
  • M Offline
    M Offline
    mejner
    wrote on last edited by
    #1

    Hi all, I have a XML files that looks like this: ... <dataset> ... <p x="-0.979248" y="-0.00141319" /> ... </dataset> ... I need to find the highest value of y. The files have 100 000 rows so it should be reasonable fast. But any suggestions are welcome.

    S 1 Reply Last reply
    0
    • M mejner

      Hi all, I have a XML files that looks like this: ... <dataset> ... <p x="-0.979248" y="-0.00141319" /> ... </dataset> ... I need to find the highest value of y. The files have 100 000 rows so it should be reasonable fast. But any suggestions are welcome.

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, first of all i wouldn't use an XML-class to load the dataset, this will be propably to slow. Try to use a stream to read the file line by line. There you could extract the y-value using a regular expression, or if all values have the same length (y is at the same index in every line) access it by its index. Then store the highest y-value somewhere and compare every y-value with this one. If the current y-value is higher overwrite the stored value. This algorithm has a complexity of O(n). If you are using multiple processors you could think about splitting the file in two or more parts and use threads to accomplish the task. Hope this helps you a bit. Regards Sebastian

      It's not a bug, it's a feature! Me in Softwareland.

      M 1 Reply Last reply
      0
      • S SeMartens

        Hi, first of all i wouldn't use an XML-class to load the dataset, this will be propably to slow. Try to use a stream to read the file line by line. There you could extract the y-value using a regular expression, or if all values have the same length (y is at the same index in every line) access it by its index. Then store the highest y-value somewhere and compare every y-value with this one. If the current y-value is higher overwrite the stored value. This algorithm has a complexity of O(n). If you are using multiple processors you could think about splitting the file in two or more parts and use threads to accomplish the task. Hope this helps you a bit. Regards Sebastian

        It's not a bug, it's a feature! Me in Softwareland.

        M Offline
        M Offline
        mejner
        wrote on last edited by
        #3

        Ah, OK. This was my first idea to solve the problem. But being an "old style" .net programmer I thought there was a more effective built in way to do it. Stream and loop, simple enough...

        I'll skip the regex and find the position fo "y = " and "/>" and grab the string between those positions.

        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