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. XML / XSL
  4. How do I get a specific value from an XML file

How do I get a specific value from an XML file

Scheduled Pinned Locked Moved XML / XSL
linuxquestioncsharptoolsxml
4 Posts 2 Posters 5 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.
  • pkfoxP Offline
    pkfoxP Offline
    pkfox
    wrote on last edited by
    #1

    Hi all, as part of my Linux build script for my SBC boards I need to download a very small XML file and parse some data, the download I achieve using wget I show a sample file below

    What I need is the url for debarm, as this is all being done in a bash script I can't use c#, anyone here know of a way to achieve this in Linux ? many thanks for reading

    In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

    K 2 Replies Last reply
    0
    • pkfoxP pkfox

      Hi all, as part of my Linux build script for my SBC boards I need to download a very small XML file and parse some data, the download I achieve using wget I show a sample file below

      What I need is the url for debarm, as this is all being done in a bash script I can't use c#, anyone here know of a way to achieve this in Linux ? many thanks for reading

      In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      As long as you know that the XML is on one line grep and sed can do the job. Assuming that the XML is in a file name data.xml:

      grep "

      Things are a bit more complicated if the XML is broken up over several lines. I'm not aware of an XML shell parser, though maybe something from python or perl might do the trick.

      "A little song, a little dance, a little seltzer down your pants"
      Chuckles the clown

      1 Reply Last reply
      0
      • pkfoxP pkfox

        Hi all, as part of my Linux build script for my SBC boards I need to download a very small XML file and parse some data, the download I achieve using wget I show a sample file below

        What I need is the url for debarm, as this is all being done in a bash script I can't use c#, anyone here know of a way to achieve this in Linux ? many thanks for reading

        In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

        K Offline
        K Offline
        k5054
        wrote on last edited by
        #3

        Ignore previous. The better way to do this is with xmllint:

        [k5054@localhost]$ xmllint --xpath "string(//debarm/@url)" data.xml
        https://downloads.lms-community.org/nightly/logitechmediaserver\_8.5.2~1715233151\_arm.deb
        [k5054@localhost]$

        "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

        pkfoxP 1 Reply Last reply
        0
        • K k5054

          Ignore previous. The better way to do this is with xmllint:

          [k5054@localhost]$ xmllint --xpath "string(//debarm/@url)" data.xml
          https://downloads.lms-community.org/nightly/logitechmediaserver\_8.5.2~1715233151\_arm.deb
          [k5054@localhost]$

          "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

          pkfoxP Offline
          pkfoxP Offline
          pkfox
          wrote on last edited by
          #4

          I just discovered this about a minute before you posted - thanks for your time :thumbsup:

          In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

          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