Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At first, you need to get substrings, where each substring contains one element that needs to be extracted:</p> <pre><code> NSArray *split = [text componentsSeparatedByString:@"&lt;td&gt;"]; </code></pre> <p>In array "split", first object contains nothing you want, so you will not work with it anymore. Now, for each substring in this array (except first one) you need to search for substring with "/td" tag:</p> <pre><code> NSRange range = [string rangeOfString:@"&lt;/td&gt;"]; </code></pre> <p>and then remove it and everything what is behind it:</p> <pre><code> - (NSString *)substringToIndex:(NSUInteger)anIndex //you will get index by searching for "&lt;/td&gt;" as mentioned </code></pre> <p>EDIT:</p> <p>Another possibility is to use componentsSeparatedByString even instead of 2nd and 3rd step for mentioned tag and in first item of each array, you will have wanted text.</p> <p>EDIT2: (whole code)</p> <pre><code> NSString* originalText = @" /&lt;html lang=""en""&gt;/&lt;body&gt;/div id=""page"" class=""container""&gt;/&lt;div class=""span-19""&gt;/&lt;div id=""content""&gt;/&lt;div&gt;/&lt;table id=yw0 class=""detail-view""&gt;/&lt;tbody&gt;/&lt;tr class=""even""&gt;/&lt;td&gt;moo1&lt;/td&gt;&lt;td&gt;moo2&lt;/td&gt;/"; NSArray* separatedParts = [originalText componentsSeparatedByString:@"&lt;td&gt;"]; NSMutableArray* arrayOfResults = [[NSMutableArray alloc] init]; for (int i = 1; i &lt; separatedParts.count; i++) { NSRange range = [[separatedParts objectAtIndex:i] rangeOfString:@"&lt;/td&gt;"]; NSString *partialResult = [[separatedParts objectAtIndex:i] substringToIndex:range.location]; [arrayOfResults addObject:partialResult]; } </code></pre> <p>I have slightly altered original text to show that its really working for table with more items inside</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload