|
|
 Rank: Devotee
Joined: 7/20/2006 Posts: 89
|
Hi, Does anybody know how to get a document by its @nodeName in .net? I can run a query in XSLT and get it, or do Document.IsNode() but that is with the id ( http://forum.umbraco.org/16191 ) I tried to run the following snippet from the cutting edge example: http://old.umbraco.org/frontpage/documentation/articles/cuttingedgeensuringuniquenames.aspxCode: foreach(umbraco.BusinessLogic.console.IconI d in documentObject.Parent.Children) { if (d.Id != documentObject.Id && d.Text == currentName) { //currentName = documentObject.Text + " (" + uniqueNumber.ToString() + ")"; //uniqueNumber++; // do my own stuff here } }
But nothing seems to cut it. No errors from the above example though, just no hit. Does anybody have some code to do this? Len.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
With XMLDOM try umbraco.library.GetXmlNodeByXPath(string xpathQuery) or with objects iterate through all items in umbraco.presentation.nodefactory.node Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
 Rank: Devotee
Joined: 7/20/2006 Posts: 89
|
I trying to go in that direction: Code: XPathNavigator xp = umbraco.content.xmlContent.CreateNavigator(); XPathNodeIterator nodes = xp.Select("//*"); string result = ""; while(nodes.MoveNext()) { XPathNavigator node = nodes.Current; result = result + node.GetAttribute("nodeName","").ToString(); result = result + node.GetAttribute("id","").ToString(); }
xpathResult.Text = "Result:" + result;
I will try with umbraco.presentation.nodefactory.node, so if it makes any difference Thx, Len
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
In xslt it is: Code:<xsl:copy-of select="umbraco.library:GetXmlNodeByXPath('.')/descendant-or-self::node [@nodeName = 'NODENAME']"/> in .Net it is Code:umbraco.library.GetXmlNodeByXPath("./descendant-or-self::node [@nodeName = 'NODENAME']") where you get an XPathNodeIterator Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
|
Guest |