Skip to main content

Partial update with Delete enabled

The following examples show how to remove some elements from an existing item (entity) with multi-occurrence elements (attributes) based on the content of a source XML stream.

Given an existing item as follows:

<Person>
	<Id>1</Id>
	<Name>p1</Name>
	<Houses>
		<House>[1]</House>
		<House>[2]</House>
		<House>[3]</House>
	</Houses>
	<Children>
		<Child>
			<Name>k1</Name>
			<Age>1</Age>
			<Habits>
				<Habit>Basketball</Habit>
				<Habit>Football</Habit>
				<Habit>Tennis</Habit>
				<Habit>Boxing</Habit>
			</Habits>
		</Child>
		<Child>
			<Name>k2</Name>
			<Age>2</Age>
		</Child>
		<Child>
			<Name>k3</Name>
			<Age>3</Age>
		</Child>
	</Children>
	<Habits>
		<Habit>Basketball</Habit>
		<Habit>Football</Habit>
		<Habit>Tennis</Habit>
		<Habit>Boxing</Habit>
	</Habits>
	<Pets>
		<Pet>Cat</Pet>
	</Pets>
	<Pets>
		<Pet>Dog</Pet>
	</Pets>
	<Pets>
		<Pet>Pig</Pet>
	</Pets>
	<Pets>
		<Pet>Cow</Pet>
	</Pets>
</Person>

Example 1: If you want to remove two child items from the existing item, then the Xpath you enter in the Pivot field must read as follows: /Person/Children/Child where the Delete check box is selected, and the Key field is set to /Name. Note that the Child element is of a complex type, and needs to be identified with the Key field. Moreover, you need to provide the source XML stream as follows:

<Person>
	<Id>1</Id>
	<Children>
		<Child>
			<Name>k2</Name>
		</Child>
		<Child>
			<Name>k3</Name>
		</Child>
	</Children>
</Person>

In this case, the two items Child [k2] and Child [k3] will be removed, and you will get the following result:

<Person>
	<Id>1</Id>
	<Name>p1</Name>
	...
	<Children>
		<Child>
			<Name>k1</Name>
			<Age>1</Age>
			<Habits>
				<Habit>Basketball</Habit>
				<Habit>Football</Habit>
				<Habit>Tennis</Habit>
				<Habit>Boxing</Habit>
			</Habits>
		</Child>
	</Children>
	...
</Person>

Example 2: If you want to remove some habits for the Person element, then the Xpath you enter in the Pivot field must read as follows: /Person/Habits/Habit where the Delete check box is selected, and the Key field is set to . or empty. Moreover, you need to provide the source XML stream as follows:

<Person>
	<Id>1</Id>
	<Habits>
		<Habit>Basketball</Habit>
		<Habit>Football</Habit>
		<Habit>Boxing</Habit>
	</Habits>
</Person>

In this case, the three habit items Habit [Basketball], Habit [Football] and Habit [Boxing] will be removed, and you will get the following result:

<Person>
	<Id>1</Id>
	<Name>p1</Name>
	...
	<Habits>
		<Habit>Tennis</Habit>
	</Habits>
	...
</Person>

Example 3: If you want to remove some habits for the Child [k1] element, then the Xpath you enter in the Pivot field must read as follows: /Person/Children/Child[1]/Habits/Habit where the Delete check box is selected, and the Key field is set to . or empty. Note that Child[1] is used in the Pivot field to identify the habits of which child will be removed. Moreover, you need to provide the source XML stream as follows:

<Person>
	<Id>1</Id>
	<Children>
		<Child>
			<Habits>
				<Habit>Basketball</Habit>
				<Habit>Football</Habit>
			</Habits>
		</Child>
	</Children>
</Person>	

In this case, the two items Habit [Basketball] and Habit [Football] will be removed, and you will get the following result:

<Person>
	<Id>1</Id>
	<Name>p1</Name>
	...
	<Children>
		<Child>
			<Name>k1</Name>
			<Age>1</Age>
			<Habits>
				<Habit>Tennis</Habit>
				<Habit>Boxing</Habit>
			</Habits>
		</Child>
		<Child>
			<Name>k2</Name>
			<Age>2</Age>
		</Child>
		<Child>
			<Name>k3</Name>
			<Age>3</Age>
		</Child>
	</Children>
	...
</Person>

Example 4: If you want to remove some pets for the Person element, then the Xpath you enter in the Pivot field must read as follows: /Person/Pets where the Delete check box is selected, and the Key field is set to /Pet. Moreover, you need to provide the source XML stream as follows:

<Person>
	<Id>1</Id>
	<Pets>
		<Pet>Cat</Pet>
	</Pets>
	<Pets>
		<Pet>Pig</Pet>
	</Pets>
</Person>

In this case, the two items Pet [Cat] and Pet [Pig] will be removed, and you will get the following result:

<Person>
	<Id>1</Id>
	<Name>p1</Name>
	...
	<Pets>
		<Pet>Dog</Pet>
	</Pets>
	<Pets>
		<Pet>Cow</Pet>
	</Pets>
</Person>

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!