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

  • SEARCH
  • Home
  • 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 6781065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:34:50+00:00 2026-05-26T16:34:50+00:00

I need to search through an HTML document for two specific strings of text

  • 0

I need to search through an HTML document for two specific strings of text in cocoa.
I am creating an NSXMLDocument with the web page: Page Example
Then I am trying to search it for the app title, and the url of the icon. I am currently using this code to search for the specific strings:

NSString *xpathQueryStringTitle = @"//div[@id='desktopContentBlockId']/div[@id='content']/div[@class='padder']/div[@id='title' @class='intro has-gcbadge']/h1";
NSString *xpathQueryStringIcon = @"//div[@id='desktopContentBlockId']/div[@id='content']/div[@class='padder']/div[@id='left-stack']/div[@class='lockup product application']/a";
NSArray *titleItemsNodes = [document nodesForXPath:xpathQueryStringTitle error:&error];
if (error)
    {
        [[NSAlert alertWithError:error] runModal];
        return;
    }
error = nil;
NSArray *iconItemsNodes = [document nodesForXPath:xpathQueryStringIcon error:&error];
    if (error)
    {
        [[NSAlert alertWithError:error] runModal];
        return;
    }

When I try to search for these strings I get the error:
“XQueryError:3 – “invalid token (@) – ./*/div[@id=’desktopContentBlockId’]/div[@id=’content’]/div[@class=’padder’]/div[@id=’title’ @class=’intro has-gcbadge’]/h1″ at line:1”

I am loosely following this tutorial.

I also tried this without all of the @ symbols in the xPath, and it also returns an error. My syntax is obviously wrong for the xPath. What would the basic syntax be for this path. I’ve seen plenty of examples with a basic XML tree, but not html.

  • 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-05-26T16:34:50+00:00Added an answer on May 26, 2026 at 4:34 pm

    I suspect it’s that part near then end where you have a test for two attributes

    /div[@id='title' @class='intro has-gcbadge']/h1";
    

    Try changing it to:

    /div[@id='title'][@class='intro has-gcbadge']/h1";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use regex to search through an html file and replace href=pagename
I need to search across multiple columns from two tables in my database using
I need to search for all users containing a certain text string in their
I need to search for a pattern in files. For example the content of
I need to search between dates and times. For example, between date: 30/02/2007, time:
I need to parse a simple HTML page with a simple form in it.
I have several custom objects in an NSArray, I need to search through all
I'm developing a web app using Django, and I'll need to add search functionality
I just need to search through all the stored procedures on my database looking
I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount%

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.