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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:17:00+00:00 2026-06-10T13:17:00+00:00

How can I check if a XML node contains text, or only empty nodes?

  • 0

How can I check if a XML node contains text, or only empty nodes?

Example: Let’s say we have the following XML:

<text>
   <p> </p>
   <p> </p>
</text>

(Note the whitespace between the p tags)

In a different XML, we have the following XML:

<text>
   <p>Hello World!</p>
</text>

I’d like the test to pass in the second example, but not in the first, as the second example contains text, but the first contains empty nodes.

Is there a way to easily achieve this?

(I use XSLT 2.0.)

  • 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-10T13:17:01+00:00Added an answer on June 10, 2026 at 1:17 pm

    If you put

    <xsl:strip-space elements="*"/>
    

    at the top of your style sheet then the parser will ignore text nodes in your input document that consist entirely of whitespace. Among other things this means that your example p elements with spaces will be treated the same as completely empty ones. For example a template matching text[p/text()] would match the text element in your second example but not ones whose p children are all empty (or contain only space).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For an XDocument descendants operation how can only return immediate child nodes? I have
Lets say I have this xml: <categories> <category text=Arts> <category text=Design/> <category text=Visual Arts/>
I have this xml, I want to check the existence of price node if
Can check out here alt text http://51hired.com/static/problem.bmp
I have a check box list in that user can check or uncheck the
for example, i have this xml <elements> <a> <b>6</b> <b>5</b> <b>6</b> </a> <a> <b>5</b>
I have a series of XML files which can be retrieved, edited and saved
i have a scenario where i need to check for the node count in
I'm looking for code which can do the following. Given a snippet of XML,
How can I check if a string contains at least one xmlNode. The string

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.