CreateChildProcessingInstruction - cXMLDOMDocumentFragment

Creates a child processing instruction

Type: Function

Return Data Type: Handle

Parameters: String sTarget String sValue

ParameterDescription
sTargetThe PI target
sValueThe PI Value


Return Value

If successful, the function returns an object handle for the newly created node. If zero is returned, the operation failed. If a node is returned, it is your responsibility to eventually destroy the object (e.g. Send Destroy of hoMyCreatedNode).


Syntax
Function CreateChildProcessingInstruction String sTarget String sValue Returns Handle

Call: Get CreateChildProcessingInstruction sTarget sValue to HandleVariable


Description

CreateChildProcessingInstruction creates a child processing instruction. This function creates an XML node but does not add it to the XML document. Nodes can be created and appended in a single step using the Add.. messages.

This is how you would add a Processing instruction to the top of your document. Assume the document has been created and the root element is defined. You want to add the processing instruction before the root element:

Get CreateChildProcessingInstruction of hoRoot "xml-myPI" "whatever you want goes here" to hoPI
Get InsertBeforeNode of hoRoot hoPI hoRoot to hoPI
Send Destroy of hoPI


Sample

This sample shows how to insert an XML declaration that specifies an XML version of 1.0 and encoding of ISO8859-1 into an XML document. The inserted XML code will look like this:

<?xml version="1.0" encoding="ISO8859-1"?>

Sample Code:

Get CreateChildProcessingInstruction Of hoXMLDocumentRoot "xml" 'version="1.0" encoding="UTF-8" standalone="yes"' To hoNodeToInsert
If (hoNodeToInsert > 0) Begin
    Get InsertBeforeNode Of hoXML hoNodeToInsert hoXMLDocumentRoot To hoInsertedNode
    If (hoInsertedNode > 0) Begin
        Send Destroy Of hoInsertedNode
    End
    Send Destroy Of hoNodeToInsert
End


Note: All XML objects created using any of the CreateXxxxx methods will create the DataFlex object as a child of the main document node (the cXmlDomDocumentObject). The actual hierarchy of your XML document has nothing to do with this object placement. The messages AppendNode, InsertBeforeNode and CloneNode determine placement of an XML node object within the document, where the object receiving the message will become the parent node.