nodesForXPath against a plain old xml in .asmx URL

59 views
Skip to first unread message

codejunky

unread,
Sep 8, 2009, 2:10:09 PM9/8/09
to KissXML
Really strange issue that I'm sure is something I'm doing wrong.
I have a .asmx url that returns a plain old XML style document.

You can see an example result on this download page:
http://tinyurl.com/necq5n

When I use nodesForXPath, I'm unable to get a result back, except for
a call to root /
If I do /ArrayOfImage/Image/ID or //ArrayOfImage/Image/ID or ./
ArrayOfImage/Image/ID, i get nothing.

Maybe useless or maybe interestingly. If I do a DDXMLElement
*something [doc rootElement]; -- the contents are the entire document,
not a tree that I can walk down in code.

Is there something about the format or characterset of the results of
a Microsoft Webservice that prevent use from KissXML?

Any help is greatly appreciated..

Nathan de Vries

unread,
Sep 8, 2009, 9:50:57 PM9/8/09
to kis...@googlegroups.com
You're not alone in your frustration -- unfortunately any XPath
implementation which adheres strictly to the XPath specification does
not support default namespaces. This includes the libxml2 library used
by KissXML.

To get around this, you can either:

1. Re-add the "urn:something:rschmi" namespace to the root element
using a named prefix like "foo" and use that prefix in your XPath
(e.g. "//foo:ArrayOfImage/foo:Image").
2. Use XPath's local-name() method (e.g. "//*[local-name()='Image']").

The TouchXML & GData libraries provide a
"nodesForXPath:namespaces:error:" API which allows you to pass in a
dictionary of namespace mappings, which would probably be a useful
addition to the KissXML library.


Cheers,

Nathan de Vries

Reply all
Reply to author
Forward
0 new messages