Get document by @nodeName Options
astuanax
Posted: Monday, November 19, 2007 1:09:04 PM

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.aspx


Code:

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.
hoehler
Posted: Monday, November 19, 2007 2:22:51 PM

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
astuanax
Posted: Monday, November 19, 2007 2:34:57 PM

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
hoehler
Posted: Monday, November 19, 2007 3:08:51 PM

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
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.