Hi. I’ve stuck in very simple at glance structure. I’m trying to get xml code like:
<InstdAmt Ccy="EUR">0.12</InstdAmt>
Dim xml as new XmlDocument
Dim attr as XMLAttribute
// <InstdAmt Ccy="EUR">0.12</InstdAmt>
dim node as XmlTextNode = xml.CreateTextNode("InstdAmt")
node.value = "0.12"
attr=xml.CreateAttribute("Ccy")
attr.value = "EUR"
node.SetAttributeNode(attr)
xml.AppendChild node
in this case I’m getting exception from string “node.SetAttributeNode(attr)” with text “msg:DOM exception 16: invalid access”
Looks like it is not possible to add attribute to XmlTextNode
Another attempt:
Dim xml as new XmlDocument
Dim attr as XMLAttribute
// <InstdAmt Ccy="EUR">0.12</InstdAmt>
dim node as XmlElement = xml.CreateElement("InstdAmt")
node.value = "0.12"
attr=xml.CreateAttribute("Ccy")
attr.value = "EUR"
node.SetAttributeNode(attr)
xml.AppendChild node
On line "node.value=“0.12"” I’m getting “msg:DOM exception 7: modification not allowed”. In the xojo wiki doc there is info about XmlElement.Value - "Not supported by all XMLNode subclasses. "
Looks like both versions are mutually exclusive.
Is there a third way? How to get xml node with attribute and value?
Thank you!