I must be making some kind of stupid mistake. I have a server that returns XML <a><b>123</b></a> , and now I would like to match this XML. So I am writing something like
xml match { case <a><b>{_}</b></a> => true }
This works until I need to deal with multi-line XML literals. Therefore, it is important that the server sends me all XML as single-line. The XML is large enough to blow a single line of code, but I cannot figure out how to do this.
The server sends <a><b>123</b><c>123</c><d>123</d><e>123</e><f>123</f></a> , and I would like to do this:
xml match { case <a> <b>{_}</b> <c>{valueOfC}</c> <d>{_}</d> <e>{_}</e> <f>{_}</f> </a> => valueOfC }
But I always get MatchError. If I write everything in one line, it will work. So the question is: how can I match XML when writing human-readable code?
Of course, I tried to find the answer through Google. Funnily enough, all examples are single-line or work recursively.
xml scala pattern-matching
Joa ebert
source share