replaceEntities replaces XML entities in the node according to the provided entity map.
(em map[string][]byte)
| 176 | // replaceEntities replaces XML entities in the node |
| 177 | // according to the provided entity map. |
| 178 | func (n *Node) replaceEntities(em map[string][]byte) { |
| 179 | // Replace in attributes |
| 180 | for attr := range n.Attrs.Iter() { |
| 181 | attr.Value = ReplaceEntitiesString(attr.Value, em) |
| 182 | } |
| 183 | |
| 184 | // Replace in children. |
| 185 | // Only Text nodes are processed, other Node children |
| 186 | // are processed recursively. |
| 187 | for _, child := range n.Children { |
| 188 | switch c := child.(type) { |
| 189 | case *Node: |
| 190 | c.replaceEntities(em) |
| 191 | |
| 192 | case *Text: |
| 193 | if !c.CData { |
| 194 | c.Data = ReplaceEntitiesBytes(c.Data, em) |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | } |
no test coverage detected