|
[Date Index]
[Thread Index]
[Author Index]
Re: repost -Difficulties with xml
- To: mathgroup at smc.vnet.net
- Subject: [mg69323] Re: repost -Difficulties with xml
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Thu, 7 Sep 2006 04:30:10 -0400 (EDT)
- Organization: Uni Leipzig
- References: <edm1b4$co5$1@smc.vnet.net>
Hi,
since you don't provide us an example of *your*
XML file
here is an other
lst =
XML`Parser`XMLGet[http://www.w3schools.com/xml/cd_catalog.xml]
and now we are looking for all the artists with
Last /@ Cases[lst, XMLElement["ARTIST", _, _],
Infinity]
and now we look for the records of "Joe Cocker"
Cases[lst, {__, XMLElement["ARTIST", _, {"Joe
Cocker"}], ___}, Infinity]
But it is up to you, if you wish to walk along the
XML tree of the
document with a recursive program or to use the
pattern matcher for
a more compact representation, i.e.
something like
Reap[lst /. {___, XMLElement["TITLE", _, title_],
___,
XMLElement["ARTIST", _, art_], ___} :>
Sow[Flatten[{art, title}]]][[2]]
to get all artists and the album title in a simple
list of pairs.
Regards
Jens
"Pascal Mercier" <pascalmercier at shaw.ca> schrieb
im Newsbeitrag news:edm1b4$co5$1 at smc.vnet.net...
| repost of my original message, which did not
make it in full the first time for some reason:
|
|
| Dear all,
|
| I am having problems accessing and changing xml
attributes/properties after importing an xml file
and I'm looking for some help.
|
| z=Import["xmltest.xml","XML"];
|
| part of z looks like the following (sorry for
the long lines here)
|
| XMLElement[ensemble, {ensemble->1}, {
XMLElement[peak, {peakID->1}, { XMLElement
[freq,{},{3.123}] , XMLElement
[vol,{},{12.12}] } ] , XMLElement[peak,
{peakID->2}, { XMLElement [freq,{},{8.101}] ,
XMLElement [vol,{},{0.552}] }]}]
| XMLElement[ensemble, {ensemble->2}, {
XMLElement[peak, {peakID->1}, { XMLElement
[freq,{},{6.163}] , XMLElement
[vol,{},{2.111}] } ] , XMLElement[peak,
{peakID->2}, { XMLElement [freq,{},{12.884}] ,
XMLElement [vol,{},{0.221}] }]}]
|
|
| Could anybody give me an hint about the correct
syntax to use to be be able to directly access and
change the value of the freq attribute of peakID2
of ensemble2 for instance?
| I just can't seem to be able to find it after
reading Mathematica's documentation.
|
| Thanks so much in advance,
|
| Pascal
|
Prev by Date:
Re: Trigonometric simplification
Next by Date:
Re: Simplify UnitStep expressions
Previous by thread:
Re: repost -Difficulties with xml
Next by thread:
plot help
|