ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / XML file functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Creates or modifies the value of an XML element or the value of the attribute for an XML element.
Example
XMLDocument("DOM")
XMLWrite("DOM","/Example/Help/Function", "Read")
XMLWrite("DOM", "Help/Function/@type", "1")
XMLWrite("DOM", "Help/Function[2]", "Write")
XMLWrite("DOM", "Help[2]/@image", "line.jpg")
XMLWrite("DOM", "Help[2]/@format", "jpg")
fSaveText("example.xml", XMLBuildString("DOM", XMLDocumentDefault, XMLEncodingIso8859_1))
XMLClose("DOM")

// generated file:
//<?xml version="1.0" encoding="ISO-8859-1"?>
//<Example>
//<Help>
//<Function type="1">Read</Function>
//<Function>Write</Function>
//</Help>
//<Help image="line.jpg" format="jpg" />
//</Example>
Syntax
<Result> = XMLWrite(<XML document> , <Path of element to create or modify> , <String to write>)
<Result>: Boolean
  • True if the element was created or modified,
  • False otherwise (the ErrorOccurred variable is set to True). To get more details on the error, use ErrorInfo.
<XML document>: Character string
Name of the XML document into which the write operation must be performed. This document contains the XML code to study and it was created by XMLDocument.
<Path of element to create or modify>: Character string
Can correspond to:
  • the path of the value to read in the XML file. To write the value of an attribute, the name of the attribute must be preceded by the "@" character.
  • the text of an XPath query to run. The XPath query must be a query for "selecting records". If several elements match the selection, the first element found is used.
If this path does not start with "/", the name of the root node is automatically added. If the XML document has no root, <Result> will correspond to <Not found>.
<String to write>: Character string
String that must be written into the specified element.
Remarks
  • XMLWrite does not modify the current position in the document.
  • Several XML browse queries cannot be nested.
  • If a filter is used to create a second element, an error will occur if the first element does not exist.
    Do:
    XMLWrite("DOM", "Help/Function", "Example")
    XMLWrite("DOM", "Help/Function[2]", "Example")

    Don't:
    XMLWrite("DOM", "Help/Function[2]", "Example")
Business / UI classification: Business Logic
Component: wd300xml.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/17/2024

Send a report | Local help