Project

Profile

Help

XPath

Added by Anonymous over 18 years ago

Legacy ID: #3778178 Legacy Poster: Sudarshan Murthy (smurthy)

When processing the result of evaluating an XPath expression I get the following exception, but only when the expression returns attributes (in C#, .NET): 'Object reference not set to an instance of an object.' Here is the code excerpt. The exception is raised in the last line of the while loop. An example offending XPath expression is: //@ID (ID is indeed an attribute of some of the elements in the input). Another offending expression is: '//Group | //@ID' (somewhat meaningless expression, but should work). Here are some expressions that work just fine: '//Group' and '//concat(@ID, position())' IEnumerator rEnum = selector.GetEnumerator(); while (rEnum.MoveNext()) { XdmItem item = (XdmItem)rEnum.Current; if (item.IsAtomic()) result += (XdmValue)item; else result += ((XdmNode)item).OuterXml; } I can replace the entire loop with either of the following statements, but the exception persists. result += (XdmValue)resultEnum.Current; result += (XdmItem)resultEnum.Current; BTW, is there a way to ask the XdmNode.OuterXml method to exclude the XML header? Thanks, SUN.


Replies (1)

RE: XPath - Added by Anonymous over 18 years ago

Legacy ID: #3778184 Legacy Poster: Sudarshan Murthy (smurthy)

Please read the posting with the correct heading 'XPath: Exception processing attribute nodes'. https://sourceforge.net/forum/forum.php?thread_id=1518319&forum_id=94027

    (1-1/1)

    Please register to reply