* OPEN MSXML Object
xmlDoc=CREATEOBJECT("Msxml2.DOMDocument.6.0")
xmlDoc.ASYNC="false"
xmlDoc.LOAD(""C:\CIUS\ft00100000000262021.xml"")
x=xmlDoc.documentElement
* INit document fragment
docFrag = xmlDoc.CreateDocumentFragment()
* Set the XML
docFrag.appendChild(xmlDoc.CreateElement("REF_J"))
* Obtain Original Node where children Exist
oNode=xmlDoc.selectnodes("/OrderReference")
i=0
* Object Creation Of children nodes to iterate
objChildNodes = oNode.ITEM(0).childNodes && (error 1)
* Iterate through children, identify the node you want to insert before
FOR EACH strNode IN objChildNodes &&(error 2)
** NODE IDENTIFIED, DO INSERT
IF strNode.nodename="REF_K" &&(error 3)
* Inserting at the location of the node with children, insert before the location of the child node.
oNode.ITEM(0).insertBefore(docFrag, oNode.ITEM(0).childNodes.ITEM(i)) &&(error 4)
EXIT FOR && (Error 5)
ENDIF
i=i+1
NEXT &&(error 6)
* Save XML
xmlDoc.SAVE("xmltest-output.xml")
because the XML file are not available, i decide to use for testing purpose my XML file UBL (in attachment), where i try to add a new node.
but unfortunately the code presented above gives me several errors, of which:
Member ITEM does not evaluate to an object. (error 1)
Property OBJCHILDNODES is not found.(error 2)
Alias 'STRNODE' is not found.(error 3)
Member ITEM does not evaluate to an object.(error 4)
Nesting error . (error 5
Nesting error . (error 6)
Someone could give some help.
Many thanks,
Luis