System.Xml.XmlException

Ciao, I’m parsing patches’ XML with a patch able to find LINK’s srcnodeid or dstnodeid attributes referring to no longer existing nodes, and to remove their entire element. I’ve succeeded in many ways, using AsXElement (XML) or XPath (XML).

But if the patch contains &cr; I see this in TTY:

00:00:17 ERR : System.Xml.XmlException in System.Xml: Riferimento a entità non dichiarata: "cr". Riga 20, posizione 77.

Stacktrace:
   in System.Xml.XmlTextReaderImpl.Throw(Exception e)
   in System.Xml.XmlTextReaderImpl.HandleGeneralEntityReference(String name, Boolean isInAttributeValue, Boolean pushFakeEntityIfNullResolver, Int32 entityStartLinePos)
   in System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
   in System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
   in System.Xml.XmlTextReaderImpl.ParseAttributes()
   in System.Xml.XmlTextReaderImpl.ParseElement()
   in System.Xml.XmlTextReaderImpl.ParseElementContent()
   in System.Xml.XmlTextReaderImpl.Read()
   in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
   in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
   in System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   in VVVV.Nodes.XML.XMLNodes.AsDocument(String xml, Validation validation)
   in VVVV.Nodes.XML.XMLAsElementNode.Evaluate(Int32 spreadMax)

Italian text in English should be reference to undeclared entity: “cr”.

In this case, Prune or GetAttribute or GetElement would return Ø thus making impossible to patch any logic after them.

Is this is a bug? Is there something I can do to prevent this error? Any workaround (beside getting dirty, and heavy, with regexpr)?

Thank you.

You’ll need to set the Validation to Dtd on the AsXElement node. Also see https://discourse.vvvv.org/t/10049.

I must be under the curse of the noob, which consists in trying with no success what devvvvs will suggest you only later. But, immediately after they say what should be done, it works. Like a charm. There’s no other explanation. I must rationalize this, or it will drive me crazy.