Append multiple elements under the active element of XML object, by specifying the path.The bottommost hierarchy element now becomes the active element. @param path The path to be added. For example, to add the hierarchy: <a> <b> <c/>
(String path)
| 260 | * @return The modified XML |
| 261 | */ |
| 262 | public XML addPath(String path) { |
| 263 | String[] elements = path.split("/"); |
| 264 | Preconditions.checkArgument(elements.length >= 1); |
| 265 | Element parent = activeElement; |
| 266 | Element newElement = null; |
| 267 | for (String element : elements) { |
| 268 | newElement = ownerDoc.createElement(element); |
| 269 | parent.appendChild(newElement); |
| 270 | parent = newElement; |
| 271 | } |
| 272 | return new XML(Objects.requireNonNull(newElement)); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Set attribute for the active element of XML object. |
no outgoing calls