在SCALA中使用Xpath修改XML

时间:2018-03-17 14:19:00

标签: xml scala xpath

对于下面给出的XML,

val doc =
<library>
  <videos>
    <vid>Head</vid>
    <video type="dvd">Seven</video>
    <video type="blue-ray">The fifth element</video>
    <video type="hardcover">Gardens of the moon</video>
  </videos>
  <books>
    <book type="softcover">Memories of Ice</book>
  </books>
</library>

需要更改XPATH中的内容:doc\("videos")\("vid") 作为<video type="usb">one</video>

因此,期望的输出是,

<library>
  <videos>
    <video type="usb">one</video>
    <video type="dvd">Seven</video>
    <video type="blue-ray">The fifth element</video>
    <video type="hardcover">Gardens of the moon</video>
  </videos>
  <books>
    <book type="softcover">Memories of Ice</book>
  </books>
</library>

欢迎使用XPATH修改XML内容的任何想法!

0 个答案:

没有答案