I have seen and tried many different versions of XML data parsing here on this forum, and even some in the documentation. Is there a tried and true "Best Practice" way to extract all the XMLElement values or is each new file type a hack a thon to extract the correct data and fields? Here's the code I'm using now, but it's not efficient and does not grab all the values needed. Is there a better way?
a=thePartIreallyneeded;
elements = Column@Cases[dat,
XMLElement[tag : _, _, value : _] :> (tag -> value), Infinity];
pairsE = List @@ elements;
gatheredE = GatherBy[pairsE, #[[1]] &];
propertiesE = Part[#, 1, 1] & /@ gatheredE;
targetPositionsE = gatheredE[[a]];
Here is a very small snippet of the section of values I'd like to extract. What I need to get are the Color Names, the Target Id values and the values for each color name. Thank you!
XMLElement[{"http://colorexchangeformat.com/CxF3-core", "Resources"}, {}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"ObjectCollection"}, {}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Object"}, {"ObjectType" -> "Target", "Name" -> "Target1",
"Id" -> "c1"}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"CreationDate"}, {}, {"2013-05-17T11:59:45-06:00"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"DeviceColorValues"}, {}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"ColorCMYK"}, {"ColorSpecification" ->
"Unknown"}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Cyan"}, {}, {"0"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Magenta"}, {}, {"0"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Yellow"}, {}, {"0"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Black"}, {}, {"0"}]}]}]}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core", "Object"}, {"ObjectType" -> "Target", "Name" -> "Target11", "Id" -> "c11"}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"CreationDate"}, {}, {"2013-05-17T11:59:45-06:00"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"DeviceColorValues"}, {}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"ColorCMYK"}, {"ColorSpecification" ->
"Unknown"}, \
{XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Cyan"}, {}, {"11.596052607559"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Magenta"}, {}, {"25.435485248175"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Yellow"}, {}, {"0"}],
XMLElement[{"http://colorexchangeformat.com/CxF3-core",
"Black"}, {}, {"0"}]}]}]}]}]}]
Import["http://www.w3schools.com/xml/simple.xml"]
$\endgroup$