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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:50:14+00:00 2026-06-05T12:50:14+00:00

I am trying to get all the text in a node for a following

  • 0

I am trying to get all the text in a node for a following set and returning as one value (not multiple nodes).

<p>
   "I love eating out."
   <br>
   <br>
   "This is my favorite restaurant."
   <br>
   "I will definitely be back"
</p>

I am using ‘/p’ and get all the results but it returns with line breaks. Also trying ‘/p/text()’ results in getting each text between each tag as a separate returned value. The ideal return would be —

"I love eating out. This is my favorite restaurant. I will definitely be back"

I’ve tried searching other questions but couldn’t find something as close. Please not that in the current environment I am restricted to only use an XPath Query and cannot parse after or setup any HTML pre-parsing. Specifically I’m using the importXML function inside of Google Docs.

  • 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-05T12:50:15+00:00Added an answer on June 5, 2026 at 12:50 pm

    Use:

    normalize-space(/)
    

    When this XPath expression is evaluated, the string value of the document node (/) is first produced and this is provided as argument to the standard XPath function normalize-space().

    By definition, normalize-space() returns its argument with the leading and trailing adjacent whitespace characters eliminated, and any interim such group of adjacent whitespace characters — replaced by a single space character.

    The evaluation of the above XPath expression results in:

    “I love eating out.” “This is my favorite restaurant.” “I will definitely be back”

    To eliminate the quotes, we additionally use the translate() function:

    normalize-space(translate(/,'&quot;', ''))
    

    The result of evaluating this expression is:

    I love eating out. This is my favorite restaurant. I will definitely be back
    

    Finally, to have this result wrapped in quotes itself, we use the concat() function:

    concat('&quot;',
           normalize-space(translate(/,'&quot;', '')),
           '&quot;'
           )
    

    The evaluation of this XPath expression produces exactly the wanted result:

    "I love eating out. This is my favorite restaurant. I will definitely be back"
    

    XSLT – based verification:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/">
      <xsl:value-of select=
       "concat('&quot;',
               normalize-space(translate(/,'&quot;', '')),
               '&quot;'
               )"/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document (corrected to be made well-formed):

    <p>
           "I love eating out."
           <br />
           <br />
           "This is my favorite restaurant."
           <br />
           "I will definitely be back"
    </p>
    

    the XPath expression is evaluated and the result of this evaluation is copied to the output:

    "I love eating out. This is my favorite restaurant. I will definitely be back"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this issue trying to get all the text nodes in an HTML
I'm trying to get all the text from a txt file into a string,
I'm trying to get all the DOM nodes that are within a range object,
I'm trying to get a node-set from a xsl variable for calculating. But my
I'm trying to get cdata text from a node using dom4j java. My issue
I am trying Node.js to get all the titles of this page: https://www.odesk.com/jobs/braintree I
I am trying to write an XQuery which would find all text nodes that
I'm trying to find all text nodes on the page using jquery. But no
I'm trying to get all edit text views to be the same size without
I am trying to get all checkboxes checked with: <script type=text/javascript> $(document).ready(function() { $(#delmsg_all).click(function()

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.