Unable to parse multiple values using XMLStarlet

Discussion in 'XML' started by kgould@yahoo.com, Aug 27, 2004.

  1. Guest

    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
    BulletinDataStore/Bulletins/Bulletinp[@BulletinID=MS98-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):

    BulletinDatastore/Bulletins/Bulletin[@BulletinID='MS98-007' and
    @BulletinLocationID='1' and @FAQLocationID='1' and
    @FAQPageName='FQ98-007.asp' and @Title='Potential SMTP and NNTP
    Denial-of-Service Vulnerabilities' and @DatePosted='1998/07/24' and
    @DateRevised='1998/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
    @ImpactSeverityID='0' and @PreReqSeverityID='0' and
    @MitigationSeverityID='0' and @PopularitySeverityID='0']
    BulletinDatastore/Bulletins/Bulletin/BulletinComments
    BulletinDatastore/Bulletins/Bulletin/QNumbers
    BulletinDatastore/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='188341']
    BulletinDatastore/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='188369']
    BulletinDatastore/Bulletins/Bulletin/Patches
    BulletinDatastore/Bulletins/Bulletin/Patches/Patch[@PatchName='MS98-007'
    and @Pa
    tchLocationID='13' and @SBID='0' and @SQNumber='188341' and
    @NoReboot='0' and @SeverityID='0']
     
    , Aug 27, 2004
    #1
    1. Advertising

  2. wrote:

    > 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 don't know XMLStarlet, but your problem can
    easily be solved with other tools.

    > 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.


    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:

    http://groups.google.de/groups?dq=&...groups?hl=de&lr=&ie=UTF-8&group=comp.lang.awk

    # 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["DateRevised"]
    print XMLATTR["Summary"]
    }

    XMLSTARTELEM == "Patch" {
    print "PatchName:", XMLATTR["PatchName"]
    }
     
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?=, Aug 27, 2004
    #2
    1. Advertising

  3. wrote in message news:<cgnpnf$>...
    > 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
    > BulletinDataStore/Bulletins/Bulletinp[@BulletinID=MS98-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):
    >
    > BulletinDatastore/Bulletins/Bulletin[@BulletinID='MS98-007' and
    > @BulletinLocationID='1' and @FAQLocationID='1' and
    > @FAQPageName='FQ98-007.asp' and @Title='Potential SMTP and NNTP
    > Denial-of-Service Vulnerabilities' and @DatePosted='1998/07/24' and
    > @DateRevised='1998/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
    > @ImpactSeverityID='0' and @PreReqSeverityID='0' and
    > @MitigationSeverityID='0' and @PopularitySeverityID='0']
    > BulletinDatastore/Bulletins/Bulletin/BulletinComments
    > BulletinDatastore/Bulletins/Bulletin/QNumbers
    > BulletinDatastore/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='188341']
    > BulletinDatastore/Bulletins/Bulletin/QNumbers/QNumber[@QNumber='188369']
    > BulletinDatastore/Bulletins/Bulletin/Patches
    > BulletinDatastore/Bulletins/Bulletin/Patches/Patch[@PatchName='MS98-007'
    > and @Pa
    > tchLocationID='13' and @SBID='0' and @SQNumber='188341' and
    > @NoReboot='0' and @SeverityID='0']


    Using XmlStarlet

    xml sel -t -v "/BulletinDatastore/Bulletins/Bulletin[@BulletinID='MS98-001']/@Summary"
    your-mssecure.xml
     
    Mikhail Grouchinsky, Aug 28, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mikhail Grouchinsky
    Replies:
    0
    Views:
    588
    Mikhail Grouchinsky
    Sep 21, 2004
  2. Replies:
    19
    Views:
    1,184
    Daniel Vallstrom
    Mar 15, 2005
  3. Bill

    xmlstarlet

    Bill, Feb 16, 2008, in forum: XML
    Replies:
    2
    Views:
    886
    Hermann Peifer
    Feb 19, 2008
  4. Viegas
    Replies:
    1
    Views:
    372
    travishein
    Aug 22, 2008
  5. 7stud --

    optparse: parse v. parse! ??

    7stud --, Feb 20, 2008, in forum: Ruby
    Replies:
    3
    Views:
    212
    7stud --
    Feb 20, 2008
Loading...

Share This Page