Unable to parse multiple values using XMLStarlet

K

kgould

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']
 
?

=?ISO-8859-1?Q?J=FCrgen_Kahrs?=

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"]
}
 
M

Mikhail Grouchinsky

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top