I'm trying to grab the site xml using GetXmlAll(), but only seem to get one node back, being root. Wanting to parse the xml in a handler, but can't seem to get it out.
The call is pretty simple
var nodes = umbraco.library.GetXmlAll()
so I'm not sure what's going wrong. Doing similar in a simple macro returns the same, just root.
You get the complete XML - but there is only ever a single root element in any valid XML file, and that's the one you get from that extension method - to access the rest you should use XPath - I'm sure if you explicitly say XPathNodeIterator or XPathNavigator in stead of plain var, you will get IntelliSense on the nodes variable, so you can do nodes.SelectSingleNode("*[@isDoc]") etc. on it to grab the specific nodes that you're looking for.
umbraco.library.GetXmlAll() only returning root
Hi all
I'm trying to grab the site xml using GetXmlAll(), but only seem to get one node back, being root. Wanting to parse the xml in a handler, but can't seem to get it out.
The call is pretty simple
so I'm not sure what's going wrong. Doing similar in a simple macro returns the same, just root.
Any ideas?
ta
Nathan
Hi Nathan,
You get the complete XML - but there is only ever a single root element in any valid XML file, and that's the one you get from that extension method - to access the rest you should use XPath - I'm sure if you explicitly say XPathNodeIterator or XPathNavigator in stead of plain var, you will get IntelliSense on the nodes variable, so you can do nodes.SelectSingleNode("*[@isDoc]") etc. on it to grab the specific nodes that you're looking for.
/Chriztian
Hi Chriztian
Thanks for that, I think I was just confusing myself - I'd tried using while(nodes.MoveNext()) with no luck.
Ended up using uQuery.GetPublishedXml and a bit of LINQ to get what I needed..
ta
Nathan
is working on a reply...