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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:58:47+00:00 2026-06-10T22:58:47+00:00

While trying to process and obtain data from an XML document, I want to

  • 0

While trying to process and obtain data from an XML document, I want to obtain a number of records using a single FLWOR expression– I am doing this by using the ‘let’ clause to obtain the data– so I have a number of rows of data.

Eg.

<div id="main">
    <p> Text #1</p>
    <p> Text #2</p>
    <p> Text #3</p>
    <p> Text #4</p>
</div>

Now, I understand how to get the 4 ‘p’ elements — however I would like to also assign a sequence number to each line — viz. I want to obtain the text this way–

 <data>Text #1</data><sequence> Sequence #1</sequence>
 <data>Text #2</data><sequence> Sequence #2</sequence>
 <data>Text #3</data><sequence> Sequence #3</sequence>
 <data>Text #4</data><sequence> Sequence #4</sequence>
  • 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-10T22:58:49+00:00Added an answer on June 10, 2026 at 10:58 pm

    There sure is a more elegant way than doing it like this…. but it works:

    let $t := <div id="main">
      <p>Text A</p>
      <p>Text B</p>
      <p>Text C</p>
      <p>Text D</p>
    </div>
    for $pos in $t/p/position()
    let $p := $t/p[$pos]
    return (
      <data>{ $p/text() }</data>,
      <sequence>Sequence { $pos }</sequence>
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While trying to process a JSON response with GSON (the output is from the
I'm getting this error from Mono's wsdl utility while trying to process eBay's WSDL
Hello I'm getting this error, while trying to save serial number to XML File.
I am trying to show a progress bar while my process is going on...in
I am trying to show a progress bar while my process is going on...in
While trying to search with id sorting (and paginating) im getting from the log:
While trying to add value into foreign key field, if same data doesn't exist
With Google Apps API , While trying to automate the process of label creation
I'm getting an error while trying to copy 4 tables from a MySQL source
While I am trying process one it's failing: Uncaught Error: INVALID_STATE_ERR: DOM Exception 11

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.