I'm doing a table join to fetch some additional information relevant to a node.
The query returns the additional information plus the xml from cmsContentXml.
Is there a helper function to cast that xml into an Umbraco node? I would like to use the node.attribute notation rather than having to parse the xml directly.
I could just use the nodeId with an Umbraco helper method, but that would seem to require a second database hit.
Hi Jon, seems like a long time ago but had to do something similar in v7 once, and the problem, if I remember correctly was that the XmlPublishedContent was internal in the core.
For our purposes, though, we were able to copy most of that core implementation into our own custom class that implemented IPublishedContent and could be constructed from the raw XML..
It turns out the easiest way to solve my problem is to load the xml into an XmlDocument and then use DOM methods. Since the page needs to display a string, creating an object is an unnecessary intermediate step.
Cast node xml into typed content
Hello
I'm using Umbraco 7.8
I'm doing a table join to fetch some additional information relevant to a node.
The query returns the additional information plus the xml from cmsContentXml.
Is there a helper function to cast that xml into an Umbraco node? I would like to use the node.attribute notation rather than having to parse the xml directly.
I could just use the nodeId with an Umbraco helper method, but that would seem to require a second database hit.
Hi Jon, seems like a long time ago but had to do something similar in v7 once, and the problem, if I remember correctly was that the XmlPublishedContent was internal in the core.
For our purposes, though, we were able to copy most of that core implementation into our own custom class that implemented IPublishedContent and could be constructed from the raw XML..
...aha, here is a gist...
https://gist.github.com/darrenferguson/0566dfba66a4a85ace413dbb553fbf04
Hope that's useful..
Regards
Marc
Thank you, Marc.
It turns out the easiest way to solve my problem is to load the xml into an XmlDocument and then use DOM methods. Since the page needs to display a string, creating an object is an unnecessary intermediate step.
is working on a reply...