Created
August 2, 2012 20:00
-
-
Save chris-twiner/3240166 to your computer and use it in GitHub Desktop.
Selecting attributes in Scales
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // http://stackoverflow.com/questions/11758607/selecting-a-xml-attribute | |
| // See https://github.com/chris-twiner/scalesXml for details on how to use | |
| // save this as loadme.scalaScript and use :load loadme.scalaScript in the repl | |
| import scales.utils.top | |
| import scales.xml._ | |
| import ScalesXml._ | |
| import Functions._ | |
| val reportxml = """<wrapper> | |
| <Sample Id="SomeId1"> | |
| <Tag Id="SomeTag"> | |
| <Lane Id="1"> | |
| [...] | |
| </Lane> | |
| </Tag> | |
| </Sample> | |
| <Sample Id="SomeId2"> | |
| <Tag Id="SomeTag"> | |
| <Lane Id="1"> | |
| [...] | |
| </Lane> | |
| </Tag> | |
| </Sample> | |
| </wrapper>""" | |
| val report = loadXml(new java.io.StringReader(reportxml)) | |
| val sampleIds = top(report).\*("Sample"l).\@("Id"l) | |
| val first = text(sampleIds) | |
| val all = sampleIds.map(text(_)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment