xpathとGDataXMLを使用してXMLを解析するのに問題があります。xpathテスターを使用すると、文字列がうまくいくように見えますが、名前空間を追加すると干渉しているようです。GDataXML、名前空間、およびxpath
XML:次のようにそれを解析する
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns='http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006'>
<Response xmlns='http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a'>
<Account>
<Protocol>
<Type>EXPR</Type>
<EwsUrl>https://server.my.dom/EWS/Exchange.asmx</EwsUrl>
</Protocol>
</Account>
</Response>
</Autodiscover>
私の試みは次のとおりです。
NSDictionary *namespaceMappings = [NSDictionary dictionaryWithObjectsAndKeys:@"http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a", @"response", nil];
NSArray *idList = [doc nodesForXPath:@"//response:Protocol[Type='EXPR']/EwsUrl" namespaces:namespaceMappings error:nil];
私はまた、次のように名前空間を除外しようとしました:
NSArray *idList = [doc nodesForXPath:@"//Protocol[Type='EXPR']/EwsUrl" error:nil];
でどちらのシナリオでも、idListのメンバーは0人です。あたかも何かがついているかどうかを知るために壁に物を投げているように感じる。誰かが私に方法を示すことができますか?
ありがとうございます!
ああ、それでした!ありがとう! – coopermj