Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:28:01+00:00 2026-06-14T04:28:01+00:00

I want to get the data between tag, from xml, using NSRegularExpression This is

  • 0

I want to get the data between tag, from xml, using NSRegularExpression

This is the xml

<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="@link" xmlns:xsi="@link" xsi:schemaLocation="@link" version="1.0">
<field left="493" top="670" right="1550" bottom="760" type="text">
<value encoding="utf-16">JENNIFER mml</value>
<line left="493" top="670" right="1550" bottom="733">
<char left="493" top="670" right="549" bottom="733" confidence="69">J</char>
<char left="565" top="670" right="605" bottom="718" confidence="71" suspicious="true">E</char>
<char left="623" top="670" right="660" bottom="718" confidence="76">N</char>
<char left="678" top="670" right="720" bottom="722" confidence="56">N</char>
<char left="736" top="674" right="776" bottom="730" confidence="80">I</char>
<char left="804" top="674" right="841" bottom="729" confidence="74">F</char>
<char left="858" top="670" right="902" bottom="725" confidence="80">E</char>
<char left="922" top="670" right="964" bottom="730" confidence="86">R</char>
<char left="965" top="670" right="1442" bottom="730" confidence="100" />
<char left="1443" top="685" right="1495" bottom="720" confidence="2" suspicious="true">m</char>
<char left="1492" top="685" right="1534" bottom="719" confidence="11" suspicious="true">m</char>
<char left="1544" top="685" right="1550" bottom="718" confidence="100" suspicious="true">l</char>
</line>
</field>
</document>

I want extract this data, between the value tag

<value encoding="utf-16">JENNIFER mml</value>

This is the ios code

 NSString *xml =@"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><document xmlns=\"@link\" xmlns:xsi=\"@link\" xsi:schemaLocation=\"@link\" version=\"1.0\"><field left=\"493\" top=\"670\" right=\"1550\" bottom=\"760\" type=\"text\"><value encoding=\"utf-16\">JENNIFER mml</value><line left=\"493\" top=\"670\" right=\"1550\" bottom=\"733\"><char left=\"493\" top=\"670\" right=\"549\" bottom=\"733\" confidence=\"69\">J</char><char left=\"565\" top=\"670\" right=\"605\" bottom=\"718\" confidence=\"71\" suspicious=\"true\">E</char><char left=\"623\" top=\"670\" right=\"660\" bottom=\"718\" confidence=\"76\">N</char><char left=\"678\" top=\"670\" right=\"720\" bottom=\"722\" confidence=\"56\">N</char><char left=\"736\" top=\"674\" right=\"776\" bottom=\"730\" confidence=\"80\">I</char><char left=\"804\" top=\"674\" right=\"841\" bottom=\"729\" confidence=\"74\">F</char><char left=\"858\" top=\"670\" right=\"902\" bottom=\"725\" confidence=\"80\">E</char><char left=\"922\" top=\"670\" right=\"964\" bottom=\"730\" confidence=\"86\">R</char><char left=\"965\" top=\"670\" right=\"1442\" bottom=\"730\" confidence=\"100\"> </char><char left=\"1443\" top=\"685\" right=\"1495\" bottom=\"720\" confidence=\"2\" suspicious=\"true\">m</char><char left=\"1492\" top=\"685\" right=\"1534\" bottom=\"719\" confidence=\"11\" suspicious=\"true\">m</char><char left=\"1544\" top=\"685\" right=\"1550\" bottom=\"718\" confidence=\"100\" suspicious=\"true\">l</char></line></field></document>";
NSString *pattern = @"<value>(\\d+)</value>";

NSRegularExpression *regex = [NSRegularExpression
                              regularExpressionWithPattern:pattern
                              options:NSRegularExpressionCaseInsensitive
                              error:nil];
NSTextCheckingResult *textCheckingResult = [regex firstMatchInString:xml options:0 range:NSMakeRange(0, xml.length)];

NSRange matchRange = [textCheckingResult rangeAtIndex:1];
NSString *match = [xml substringWithRange:matchRange];
NSLog(@"Found string '%@'", match);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:28:02+00:00Added an answer on June 14, 2026 at 4:28 am

    Your current regex only matches a precise <value> tag and a number with \d+.

    <value>(\d+)</value>
    

    However, your input has an attribute (encoding="utf-16") and doesn’t contain a number as the value (JENNIFER mml):

    <value encoding="utf-16">JENNIFER mml</value>
    

    To overcome the first issue, you can either hardcode the attribute into the regex, or modify the pattern slightly:

    <value encoding="utf-16">
    or
    <value[^>]*>
    

    To match the value of the tag, as it appears to be alphabetical (with whitespace), and we’ll throw in numbers too, you could use:

    [a-zA-Z0-9\s]+
    

    So, altogether you could try:

    <value[^>]*>([a-zA-Z0-9\s]+)</value>
    

    With your current code (for copy+paste):

    NSString *pattern = @"<value[^>]*>([a-zA-Z0-9\\s]+)</value>";
    

    UPDATE (anything can match between <value></value>)
    Per a comment, the exact text between the <value></value> tags can contain any character, not just alphanumeric. To handle this, we can just match everything with (.*):

    <value>[^>]*>(.*)</value>
    

    With your current code:

    NSString *pattern = @"<value[^>]*>(.*)</value>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I want get data I already have accessed from javascript and passing it
I want to get data from mysql database with the help of DataImportHandler so
I want to get data from table in MySQL and to show it in
I want to get data using CURL but I have a problem. When I
I want to get data from two tables. I have patient first name and
I want to get data from a table in my MySQL database. $linkID =
I want to get data from two tables with single Entity class. How?? public
Whenever I want to get data from a plist file I use the following
Here's the scenario, I want to get Data from the Service to Activity Whenever
i am new to asp.net, ı want to get data from url on asp.net.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.