remove_element Method

Removes the elment as the specified XPath.

Syntax

def remove_element() -> None: ...

Remarks

This method removes the element specified by x_path.

When called the class will remove the element and its children from the internal representation of the XML (the DOM). This may be used at any time after parse returns, or from within the on_end_element event as a document is parsed in order to remove sections of a document that will not be needed later. By removing unnecessary elements from the DOM memory consumption is reduced and overall performance is improved.

RemoveElement Example:

Given the XML

<food>
	<fruits>
		<apple>
			<color>red</color>
		</apple>
		<banana>
			<color>yellow</color>
		</banana>
	</fruits>
</food>

This code removes the apple element and its children.


xml.XPath = "/food/fruits/apple";
xml.RemoveElement(); 

The XML stored in the DOM is now:

<food>
	<fruits>
		<banana>
			<color>yellow</color>
		</banana>
	</fruits>
</food>

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks 2020 Python Edition - Version 20.0 [Build 8307]