-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Could you give an example that can loop on each element, and do some transformation?
Say, an XML:
<div>
<div class="header">This is header</div>
<p class="body>This is body</p>
</div>Is it possible to write a macro, which can add the id attribute to each tag? An also change the content of This is header.
The final xml element will be:
<div id="1">
<div id="2" class="header">This is header !!!!</div>
<p id="3" class="body>This is body</p>
</div>
The id value is not important, I just want to find a way to do something to each element, use pattern matching, like:
def transform(elem:Tree): Tree = {
elem match {
case q"<div>...</div>" => ...
case q"<p>...</p>" => ...
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels