MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

XMLElement with sub-elements?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68322] XMLElement with sub-elements?
  • From: "AngleWyrm" <anglewyrm at yahoo.com>
  • Date: Tue, 1 Aug 2006 06:59:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
I want to extract a couple pieces of info from an XML record. I can get just 
one XMLElement child element easily enough, but how to get several?

For example, an xml record set
<recordset>
 <improvement>
  <name>Basic Factory</name>
  <industry>10</industry>
 </improvement>
 <-- more records -->
</recordset>

To get all industry values, I can gather all cases where the XMLElement 
contains an XMLElement "Industry", like so:

improvements = Import[ filename, "XML"];
factories = Cases[improvements, XMLElement[_, _,
{___, XMLElement["Industry", _, {industry_}], ___}
] -> {industry}, Infinity]

How would I get the names AND industry values into a list? 



  • Prev by Date: Re: need to make a special function
  • Next by Date: Re: need to make a special function
  • Previous by thread: Re: Using implicit information about row indices
  • Next by thread: Re: XMLElement with sub-elements?