New answers tagged

2

BusPhysParamMod[xmlString_, name_, pName_] := Cases[Cases[xmlString, XMLElement[ "SomeVehicle", _, {___, XMLElement["Name", _, {name}], ___}], Infinity], XMLElement[ "Bus", _, {___, XMLElement[ pName, {___, "unit" -> unit_}, {dim_}], ___}] :> {ToExpression[ dim], unit}, ...


1

I think that using Cases to break apart XML is probably not the right way to go. When working with the nested structure like this, the natural approach is to use recursion. The following code could use polishing but it suggests a general way to deal with XML. The basic idea is that you find the head of the structure and strip it off, then recurse on what's ...


Top 50 recent answers are included