Unable to parse multiple values using XMLStarlet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kgould@yahoo.com

    Unable to parse multiple values using XMLStarlet

    I'm trying to use XMLStarlet to pull a value out of Microsoft's
    mssecure.xml file for patch availability. I'm an XML newb, so I'm
    struggling here.

    I want to pull the @Summary field value- I'm unable to see from the
    examples how to handle pulling one of these multiple values. I don't
    want to use a template.

    I tried

    xml sel -t -m
    BulletinDataSto re/Bulletins/Bulletinp[@BulletinID=MS9 8-007] to see if I
    could get anything - nothing. I'm missing some point here.


    The file is like this (from xml el -v mssecure.xml):

    BulletinDatasto re/Bulletins/Bulletin[@BulletinID='MS 98-007' and
    @BulletinLocati onID='1' and @FAQLocationID= '1' and
    @FAQPageName='F Q98-007.asp' and @Title='Potenti al SMTP and NNTP
    Denial-of-Service Vulnerabilities ' and @DatePosted='19 98/07/24' and
    @DateRevised='1 998/09/09' and @Supported='Yes ' and @Summary='This issue
    involves a denial of service vulnerability that can potentially be used
    by someone with malicious intent to unexpectedly cause multiple
    components of the Microsoft Exchange Server to stop.' and @Issue='' and
    @ImpactSeverity ID='0' and @PreReqSeverity ID='0' and
    @MitigationSeve rityID='0' and @PopularitySeve rityID='0']
    BulletinDatasto re/Bulletins/Bulletin/BulletinComment s
    BulletinDatasto re/Bulletins/Bulletin/QNumbers
    BulletinDatasto re/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='18834 1']
    BulletinDatasto re/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='18836 9']
    BulletinDatasto re/Bulletins/Bulletin/Patches
    BulletinDatasto re/Bulletins/Bulletin/Patches/Patch[@PatchName='MS9 8-007'
    and @Pa
    tchLocationID=' 13' and @SBID='0' and @SQNumber='1883 41' and
    @NoReboot='0' and @SeverityID='0']

  • Jürgen Kahrs

    #2
    Re: Unable to parse multiple values using XMLStarlet

    kgould@yahoo.co m wrote:
    [color=blue]
    > I'm trying to use XMLStarlet to pull a value out of Microsoft's
    > mssecure.xml file for patch availability. I'm an XML newb, so I'm
    > struggling here.[/color]

    I don't know XMLStarlet, but your problem can
    easily be solved with other tools.
    [color=blue]
    > I want to pull the @Summary field value- I'm unable to see from the
    > examples how to handle pulling one of these multiple values. I don't
    > want to use a template.[/color]

    The attached script is written for use with xmlgawk,
    an extension of GNU Awk. The script prints the IDs
    of all bulletins along with a summary and the names
    of all patches like this:

    Bulletin MS98-007 1998/09/09
    This issue involves a denial of service vulnerability that can potentially be used by someone with m
    alicious intent to unexpectedly cause multiple components of the Microsoft Exchange Server to stop.
    PatchName: psp2stri.exe
    PatchName: psp2imsi.exe
    PatchName: MS98-007

    If you would like to use the script, you will probably
    need a bit more info about xmlgawk:



    # mssec.awk
    # Reads a file containing MS-related bulletins about
    # patches named mssecure.xml. The data comes as an
    # XML document from standard input. An overview is
    # printed on standard output. More recent versions
    # of the file can be downloaded here:
    # https://xml.shavlik.com/mssecure.xml
    # JK 2004-08-27

    BEGIN { XMLMODE=1 }

    XMLSTARTELEM == "Bulletin" {
    print "\nBulletin ", XMLATTR["BulletinID "], XMLATTR["DateRevise d"]
    print XMLATTR["Summary"]
    }

    XMLSTARTELEM == "Patch" {
    print "PatchName: ", XMLATTR["PatchName"]
    }


    Comment

    • Mikhail Grouchinsky

      #3
      Re: Unable to parse multiple values using XMLStarlet

      kgould@yahoo.co m wrote in message news:<cgnpnf$gr 1@odak26.prod.g oogle.com>...[color=blue]
      > I'm trying to use XMLStarlet to pull a value out of Microsoft's
      > mssecure.xml file for patch availability. I'm an XML newb, so I'm
      > struggling here.
      >
      > I want to pull the @Summary field value- I'm unable to see from the
      > examples how to handle pulling one of these multiple values. I don't
      > want to use a template.
      >
      > I tried
      >
      > xml sel -t -m
      > BulletinDataSto re/Bulletins/Bulletinp[@BulletinID=MS9 8-007] to see if I
      > could get anything - nothing. I'm missing some point here.
      >
      >
      > The file is like this (from xml el -v mssecure.xml):
      >
      > BulletinDatasto re/Bulletins/Bulletin[@BulletinID='MS 98-007' and
      > @BulletinLocati onID='1' and @FAQLocationID= '1' and
      > @FAQPageName='F Q98-007.asp' and @Title='Potenti al SMTP and NNTP
      > Denial-of-Service Vulnerabilities ' and @DatePosted='19 98/07/24' and
      > @DateRevised='1 998/09/09' and @Supported='Yes ' and @Summary='This issue
      > involves a denial of service vulnerability that can potentially be used
      > by someone with malicious intent to unexpectedly cause multiple
      > components of the Microsoft Exchange Server to stop.' and @Issue='' and
      > @ImpactSeverity ID='0' and @PreReqSeverity ID='0' and
      > @MitigationSeve rityID='0' and @PopularitySeve rityID='0']
      > BulletinDatasto re/Bulletins/Bulletin/BulletinComment s
      > BulletinDatasto re/Bulletins/Bulletin/QNumbers
      > BulletinDatasto re/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='18834 1']
      > BulletinDatasto re/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='18836 9']
      > BulletinDatasto re/Bulletins/Bulletin/Patches
      > BulletinDatasto re/Bulletins/Bulletin/Patches/Patch[@PatchName='MS9 8-007'
      > and @Pa
      > tchLocationID=' 13' and @SBID='0' and @SQNumber='1883 41' and
      > @NoReboot='0' and @SeverityID='0'][/color]

      Using XmlStarlet

      xml sel -t -v "/BulletinDatasto re/Bulletins/Bulletin[@BulletinID='MS 98-001']/@Summary"
      your-mssecure.xml

      Comment

      Working...