On 11/07/2010 21:25, Tom Sturgeon wrote:
I get the following XPathException when trying to retrieve the value of an attribute:
"{"XPath syntax error at char 49 in {...']/*:OutputSchedule/*:@enab...}:\n    expected \"<name>\", found \"@\""}"

The XPath statement is:
/Manager/Output[@id='5']/OutputSchedule/@enabled

The error message suggests otherwise. It suggests that your XPath expression is something like

/Manager/Output[@id='5']/*:OutputSchedule/*:@enabled

In which case "*:@enabled" should be changed to @*:enabled.

Michael Kay
Saxonica


The XML is:
<Manager>
<Output id="5" Channel="5">
<OutputName>Foo</OutputName>
<OutputValue>On</OutputValue>
<OutputControl>Automatic</OutputControl>

<OutputSchedule enabled="1">
<Sunday enabled="1" start="00:00" stop="00:00"/>
<Monday enabled="0" start="00:00" stop="00:00"/>
<Tuesday enabled="1" start="00:00" stop="00:00"/>
<Wednesday enabled="0" start="00:00" stop="00:00"/>
<Thursday enabled="1" start="00:00" stop="00:00"/>
<Friday enabled="0" start="00:00" stop="00:00"/>
<Saturday enabled="1" start="00:00" stop="00:00"/>
</OutputSchedule>
</Output>
</Manager>

----------------------------------------------------------------------
I can get to OutputName, OutputValue and OutputControl just fine, but I really want enabled in OutputSchedule.

I am using the 4/26/2010 release of Saxon9he on .NET.

Here is the C# code:
 string xPath = FixXPath(el.tagXPath).TrimEnd();
                    XPathSelector mySelector = null;

                    try
                    {
                      
                        mySelector = myCompiler.Compile(xPath).Load();
                        mySelector.ContextItem = myNode;
                    }

                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

-----------------------------------------------------------------------------------
Again, the above code works fine with non-attributes.

Any assistance would be greatly appreciated.

Sincerely,
Tom S.
------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help