Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I want to get paging record from .NET usercontrol. This is my code but I get exception
System.Xml.XPath.XPathException: 'descendant::node()[@id='1349']/child::node()[position() >= 0 and position() <= 5]' has an invalid token.
string xPath="descendant::node()[@id='1349']/child::node()[position() >= 0 and position() <= 5]";
List<Node> nodes = new List<Node>();
XPathNavigator xPathNavigator = umbraco.content.Instance.XmlContent.CreateNavigator(); XPathNodeIterator xPathNodeIterator = xPathNavigator.Select(xPath); Node node; while (xPathNodeIterator.MoveNext()) { node = UmbracoHelper.GetNode(xPathNodeIterator.Current.Evaluate("string(@id)").ToString()); if (node != null) { nodes.Add(node); } }
I created a test.xslt in .net , The strange thing is there is no error with the same code
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="descendant::node()[@id='1349']/child::* [position() >= 0 and position() <= 5]"/>
</xsl:template>
</xsl:stylesheet>
Hi Yumin
What version of Umbraco are you using?
/Jan
hi Jan Skovqaard
Umbraco.4.10.0
Hi Yumin,
Try something like this, I haven'ttest it myself.
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:value-of select="$currentPage/descendant::*[@isDoc and @id='1349' ]/child::* [position() >= 0 and position() <= 5]"/> </xsl:template></xsl:stylesheet>
I hope this can helps you further.
/Dennis
hi all,
thanks very much,I have solved the problem
xpath expression can not use > and < in .net, Otherwise will get a invalid token exception
use > and < instead
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
XPathException:has an invalid token
I want to get paging record from .NET usercontrol. This is my code but I get exception
System.Xml.XPath.XPathException: 'descendant::node()[@id='1349']/child::node()[position() >= 0 and position() <= 5]' has an invalid token.
string xPath="descendant::node()[@id='1349']/child::node()[position() >= 0 and position() <= 5]";
List<Node> nodes = new List<Node>();
XPathNavigator xPathNavigator = umbraco.content.Instance.XmlContent.CreateNavigator();
XPathNodeIterator xPathNodeIterator = xPathNavigator.Select(xPath);
Node node;
while (xPathNodeIterator.MoveNext())
{
node = UmbracoHelper.GetNode(xPathNodeIterator.Current.Evaluate("string(@id)").ToString());
if (node != null) { nodes.Add(node); }
}
I created a test.xslt in .net , The strange thing is there is no error with the same code
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="descendant::node()[@id='1349']/child::* [position() >= 0 and position() <= 5]"/>
</xsl:template>
</xsl:stylesheet>
Hi Yumin
What version of Umbraco are you using?
/Jan
hi Jan Skovqaard
Umbraco.4.10.0
Hi Yumin,
Try something like this, I haven'ttest it myself.
I hope this can helps you further.
/Dennis
hi all,
thanks very much,I have solved the problem
xpath expression can not use > and < in .net, Otherwise will get a invalid token exception
use > and < instead
is working on a reply...