Page 1 of 1

Allow InsertAndUpdateNode to Work With Attributes and Value

Posted: April 17th, 2023, 5:18 pm
by JefferyD
InsertAndUpdateNode is a great way for finding and editing the child of a specific node in XML, but there are no good options when dealing with attributes or values of nodes. It could be useful if InsertAndUpdateNode was expanded on to allow these cases as well.

Suggestion
Add special node names to target aspects of a node other than its children:
  • "#text" or "text()" - Sets the text value directly stored in the parent node
  • "@[attribute name]" - Sets the value of an attribute with a name that matches "[attribute name]"
"#text" is a common way that XML parsers denote a text node as opposed to an element node.
"text()" and "@[attribute name]" are part of the XML specification for targeting text and attribute nodes respectively.


Attribute Example
Given the following service:
image.png

An InsertAndUpdateNode can be configured like so to add a "charCount" attribute containing the character count of each node:
image.png
image.png

Re: Allow InsertAndUpdateNode to Work With Attributes and Value

Posted: April 17th, 2023, 5:57 pm
by JefferyD
Another idea that came to me is using "#name" or "name()" as a node name to allow renaming a given node without affecting its contents or attributes.

So "#text" or "text()" for adding or changing the text of a node,
"#name" or "name()" for changing the name of a node,
"@[name]" for adding or updating the value of an attribute of a node,
and "[name]" the current behavior of adding or updating a child of a node.