1 ...">

Xerces: How to merge duplicate nodes?

My question is:

If I have the following XML:

<root>
  <alpha one="start">
    <in>1</in>
  </alpha>
</root>

and then add the following path:

<root><alpha one="start"><out>2</out></alpha></root>

that leads to

<root>
  <alpha one="start">
    <in>1</in>
  </alpha>
</root>
<root>
  <alpha one="start">
    <out>2</out>
  </alpha>
</root>

I want to be able to convert it to this:

<root>
  <alpha one="start">
    <in>1</in>
    <out>2</out>
  </alpha>
</root>

Besides the fact that he himself was implementing (today I do not want to reinvent the wheel), is there a concrete way in Xerces (2.8, C ++) to do this?

If so, at what point in the DOMDocuments node merge is done? with each insert? when writing a document, explicitly on request?

Thanks.

+3
source share
2 answers

If you use xalan, then you can use xpath to search for the element and directly insert it into the correction.

, "root" elments "one", "start".

selectNodes("//root[@one="start"]")

,

selectNodes("/abc/def/.../root[@one="start"]")

selectNodes("./root[@one="start"]")

, xpath wikipedia.

+1

, , ?

alpha XML alpha, .

, . Xerces, libxml ++ .

0

Source: https://habr.com/ru/post/1709939/


All Articles