Showing posts with label ltdata. Show all posts
Showing posts with label ltdata. Show all posts

Friday, March 9, 2012

Problem Xquery about XML node called 'data'

I have a xml code:
<root>
<data id="1">
<value>80</value>
</data>
</root>

I execute the following query XQuery in C# .NET:

For $b IN document(\"filename.xml\")/root/data
WHERE $b/@.id =\"1\" RETURN $b/value

and XQuery show me the following error:

'(' expected. Maybe you are using a known function name like last, data, text etc as an identifier. For this release , this is not allowed.

I can't change the name "data" for my Xml Node so
how can I solve my problem using the word "data" in XQuery?

Dear Luigi

Note that the XQuery engine in C# .Net was just a technology preview and is not supported.

One way to work around your problem is to replace /root/data with /root/*[local-name() = "data"].

Best regards
Michael|||Thank you,
but function local-name() generate an error:

User Defined Functions not supported

This error is try with other function eg. concat, tokenize, upper-case, etc.

I using XQuery Demo: Microsoft.Xml.XQuery.dll (19/02/2002)

Exists one more recent version?

|||You may need to use fn:local-name() instead.

Note that the demo is not supported and no newer version is available.