Finding the first child of an XML Elem in Scala
So, I'm working on a project which can receive multiple types of XML
requests. The type of the request is determined by the first child of the
root tag. So you could get something like this:
<a>
<b>
foo
</b>
</a>
or:
<a>
<c>
foo
</c>
</a>
And perform a certain operation on foo, based on whether the first child
of <a> is <b> or <c>. I can't figure out any simple way to determine the
first child of . I suppose I could do repetitive matching, first checking
for a \ 'b' then a \ 'c', etc. But I need to handle a bunch of different
request types, so this would get unwieldy quick. Elem.child isn't helpful,
it just returns a one-element list: the Element itself.
How can I get the first child of an Element, without knowing beforehand
the name of the tag?
No comments:
Post a Comment