Mittwoch, 8. Mai 2019

xml node replacement variant (schematic)

schema - xmlsuit is decoration only - Document object required - REPLACEMENT variant

use org.w3c.dom.Document
use org.w3c.dom.NodeList
use org.w3c.dom.Node
use org.w3c.dom.NamedNodeMap
use org.w3c.dom.Element
declare auto Document d!
declare auto NodeList nl!
declare auto Node n!
declare auto Node c!
declare Element e!
declare xmlsuit xml!declare auto Node newHeaderNode!
markup$="<?xml version=""1.0"" encoding=""UTF-8""?><MESSAGE DTD=""XMLMSG"" VERSION=""1.0""><HEADER><FROM>.....</DATA></REQUEST></COMMAND></MESSAGE>"
xml!=new xmlsuit(markup$)d!=xml!.getDocument()
n!=xml!.getDocument().getFirstChild(); REM MESSAGE
c!=n!.getFirstChild(); REM HEADER
newHeaderNode!=c!.cloneNode(Boolean.FALSE)
nl!=d!.getElementsByTagName("COMMAND")
e!=d!.createElement("NEWTAG")
e!.appendChild(newHeaderNode!)
REM nl!.item(0).getParentNode().insertBefore(newHeaderNode!,nl!.item(0))nl!.item(0).getParentNode().insertBefore(e!,nl!.item(0))
n!.removeChild(c!)
?xml!.getDocumentAsPrettyString().substring(0,1000)

Keine Kommentare:

Kommentar posten