0

特定の xml Web サービスのこの & タグに問題があります。

     <description>I am trying to find in a timely manner: 1) 2 ea. fast unload solenoid 
    valves/Coils 2) 2 ea. Load Solenoid Valves &amp; Coils 3) 2 ea. Unload Normal
     Solenoid Valves/Coils for the following: Model # SSCA075AN Serial #0277468</description>

上記の xml を nsxmlparser で解析した後、以下のようになります。

      I am trying to find in a timely manner: 1) 2 ea. fast unload solenoid valves/Coils   2) 2 ea. Load Solenoid Valves 
      &
      amp; Coils 3) 2 ea. Unload Normal Solenoid Valves/Coils for the following: Model # SSCA075AN Serial # 0277468

組み合わせた文字列で表示する必要があります。

4

2 に答える 2

0

以下のメソッドを使用して、html タグを削除します。

- (NSString *)removeHTMLTags:(NSString *)str
{
   NSMutableString *htmlStr = [NSMutableString stringWithCapacity:[str length]];

   NSScanner *scanner = [NSScanner scannerWithString:str];
   NSString *tempText = nil;

   while (![scanner isAtEnd])
   {
    [scanner scanUpToString:@"<" intoString:&tempText];

    if (tempText != nil)
        [htmlStr appendString:tempText];

    [scanner scanUpToString:@">" intoString:NULL];

    if (![scanner isAtEnd])
        [scanner setScanLocation:[scanner scanLocation] + 1];

    tempText = nil;
  }
  return htmlStr;
}
于 2012-08-23T05:49:20.343 に答える