PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Example for using the XMLDelete function
XMLDelete (Example)
Example for using the XMLDelete function
XMLSource is string
Res is boolean

// Load an existing XML file
XMLSource = fLoadText(fExeDir() + ["\"] + "Example.xml")
Res = XMLDocument("XMLDoc", XMLSource)

// Was the document created?
IF Res = False THEN
Error("The document was not created.")
RETURN
END

// Find the first "Connection" tag
XMLFind("XMLDoc", "Connection", XMLTag, XMLExact)

// Delete the entire tag
XMLDelete("XMLDoc")

// Save the modified XML file
XMLSource = XMLBuildString("XMLDoc")
fSaveText(fExeDir() + ["\"] + "ModifiedExample.xml", XMLSource)
Content of the "Example.xml" file:
<CONNECTIONS>
<Connection>
<ConnectionName>NameConnectionOne</ConnexionName>
<Supplier>6</Supplier>
<DataSource>DataSourceOne</DataSource>
<Database>Database1</Database>
<User>User1</User>
<Password>Pass1</Password>
</Connection>
<Connection>
<ConnectionName>NameConnectionX</ConnectionName>
<Supplier>5</Supplier>
<DataSource>DataSource2</DataSource>
<Database>Database2</Database>
<User>User2</User>
<Password>Pass2</Password>
</Connection>
</CONNECTIONS>
Content of the "ModifiedExample.xml" file:
<CONNECTIONS>
<Connection>
<ConnectionName>NameConnectionX</ConnectionName>
<Supplier>5</Supplier>
<DataSource>DataSource2</DataSource>
<Database>Database2</Database>
<User>User2</User>
<Password>Pass2</Password>
</Connection>
</CONNECTIONS>
Minimum version required
  • Version 15
This page is also available for…
Comments
Click [Add] to post a comment