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 8338701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:40:34+00:00 2026-06-09T04:40:34+00:00

I am working to extract some content from a web page. Given below is

  • 0

I am working to extract some content from a web page.

Given below is the XQuery code I am using. I am using a XQuery library to parse through XML which is obtained by transforming a HTML web page into XML. After that I am extracting some specific content from that XML page:

declare variable $doc as node() external;

let $select_block := $doc//div[@class="randomclass" and contains(.,'MatchingText')]
for $select_link in $select_block/a 
for $select_link_url in $select_link/@href
where contains($assignee_link_url, 'inassignee')  
return data($select_link)

From above, you can see that variable $select_block tries to extract content of that div of web page which has class="randomclass", and which contains the text “MatchingText”.

Now, if the web page in question does not contain such a block, then how do I return a default value for $select_link? Basically, I want to tackle the scenario where no value is returned for a selection within an XQuery expression so that I can mark a flag that tells the user that this value was not found.

  • 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-09T04:40:35+00:00Added an answer on June 9, 2026 at 4:40 am

    An if/then/else construct will probably do what you want. An example:

    declare variable $doc as node() external;
    
    let $select_block := $doc//div[@class="randomclass" and contains(.,'MatchingText')]
    return if($select_block) then (
      for $select_link in $select_block/a 
      for $select_link_url in $select_link/@href
        where  contains($assignee_link_url,'inassignee')  
      return data($select_link)
    ) else (
      'default value'
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am currently using SAX to try and extract some information from a
Here is an extract for some code that I am working on. Just wondering
I'm working with mysql (5.1) ruby (1.8.7) connector to extract some data from a
I'm trying to extract some information from web server log and it's not very
I am working on a SSIS package that extracts some data from DB to
I'm trying to extract the minimum from a binary heap but it's not working.
I am working with XPATH, Java and want to extract some text out of
I'm trying to use Selenium (in Python) to extract some information from a website.
I'm working on #huge# text files (from 100mb to 1gb), I have to parse
I'm using PHP's simplexml_load_file to get some data from Flickr. My goal is to

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.