|
|
|
|
|
- Declaring an xmlNode variable
- Properties specific to xmlNode variables
xmlNode (Variable type) In french: xmlNoeud
The xmlNode type is used to handle a node of an XML document. You can define and change the characteristics of this node using different WLanguage properties. This type of variable is used by: Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
MyXMLText is string = [
<?xml version="1.0"?>
<!DOCTYPE PLAY SYSTEM "play.dtd">
<PLAY>
<TITLE>The Tragedy of Romeo AND Juliet</TITLE>
<ACT><TITLE>ACT I</TITLE>
<PROLOGUE><TITLE>PROLOGUE</TITLE></PROLOGUE>
<SCENE><TITLE>SCENE I. Verona. to PUBLIC place.</TITLE></SCENE>
</ACT>
<ACT><TITLE>ACT II</TITLE>
<PROLOGUE><TITLE>PROLOGUE</TITLE></PROLOGUE>
<SCENE><TITLE>SCENE I. to lane by the wall of Capulet's orchard.</TITLE></SCENE>
</ACT>
<ACT><TITLE>ACT III</TITLE>
<PROLOGUE><TITLE>PROLOGUE</TITLE></PROLOGUE>
<SCENE><TITLE>SCENE I. to PUBLIC place.</TITLE></SCENE>
</ACT>
</PLAY>
]
RomeoAndJuliet is xmlDocument
RomeoAndJuliet = XMLOpen(MyXMLText, fromString)
Act is xmlNode
FOR EVERY ACT of RomeoEtJuliette.PLAY ON ACT
Trace(Act.TITLE)
END
cMyNode is xmlNode, description="ProjectXSDSchema.RootNode"
cMyNode.Text = "21"
IF XMLValidNode(cMyNode) = False THEN
Error(ErrorInfo())
ELSE
Info("The XML node is valid")
END
Remarks Declaring an xmlNode variable The xmlNode variables can be declared by specifying a template node (node in an XSD file). The structure of this document will be read by WINDEV and the automatic completion will be available for the names of nodes in the code editor. To declare an xmlNode variable with a sample document: - Add the XML or XSD document into the project.
- The XML or XSD document appears in the project browser, in the "XML descriptions" branch. You have the ability to see its structure.
- Declare the variable as follows:
<Variable name> is xmlNode, description = <Path of node in XSD document>
Note: the node declaration syntax can also be obtained by dragging and dropping the node from the project explorer.. The child nodes of the variable can now be directly accessed by their names. These names are automatically proposed by the automatic completion mechanism of the code editor. Properties specific to xmlNode variables The following properties can be used to handle xmlNode variables: | | | Name | Type used | Effect |
---|
Attribute | Array of xmlAttribute | Array of XML attributes associated with the node. | ChildNode | Array of xmlNode | Array of child nodes. | Exist | Boolean | - True if the node exists,
- False otherwise.
In read mode, this property is used, for example, to test the existence of a particular child of a document node. New in version 2025When writing, assigning this property to Vrai forces the creation of an empty node. New in version 2025This property is now available in writing. | Name | Unicode string | Node name. | Namespace | xmlNamespace variable | XML namespace of node. | NamespaceDeclared | Array of xmlNamespace | Array of XML namespaces declared by the node. | Occurrence | Integer | Number of nodes of same level and with the same name in the XML document. This property is read-only. | Text | Unicode string | Text found in the node. | Type | Integer | Type of node. The possible types are as follows:- XMLBalise (default): Simple XML node that can contain children.
For example:
<NODE> <CHILDNODE> </CHILDNODE> </NODE> - XMLText XML node containing text.
For example:
- XMLCDATA: XML node containing data that must be ignored by the XML parser..
For example:
<NODE><![CDATA[This data is not processed by the XML analyzer]]> </NODE>
Remarks: - The type can be assigned once only. Then, the property is read-only.
- If a value is assigned to the Name property, the node will automatically be of type XMLTag.
- If a value is assigned to the Text property, the node will automatically be of type XMLText.
- When a value is assigned to the Text property, all the child nodes of type XMLText and XMLCData are deleted.
| XMLSource | Unicode string | Fragment of XML code corresponding to the node. This property also returns the XML code of the child nodes. This property is read-only. |
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|