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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:36:20+00:00 2026-05-27T23:36:20+00:00

How I can find in XPath 1.0 all rows with empty col name=POW ?

  • 0

How I can find in XPath 1.0 all rows with empty col name="POW"?

<row>
<col name="WOJ">02</col>
<col name="POW"/>
<col name="GMI"/>
<col name="RODZ"/>
<col name="NAZWA">DOLNOŚLĄSKIE</col>
<col name="NAZDOD">województwo</col>
<col name="STAN_NA">2011-01-01</col>
</row>

I tried many solutions. Few times in Firefox extension XPath Checker selection was ok, but lxml.xpath() says that expression is invalid or just returns no rows.

My Python code:

from lxml import html
f = open('TERC.xml', 'r')
page = html.fromstring(f.read())
for r in page.xpath("//row[col[@name = 'POW' and not(text())]]"):
    print r.text_content()
    print "-------------------------"
  • 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-27T23:36:21+00:00Added an answer on May 27, 2026 at 11:36 pm

    How I can find in XPath 1.0 all rows with empty col name="POW"?

    There are many possible definitions of “empty” and for each one of them there is a different XPath expression selecting “empty” elements.

    A reasonable definition for an empty element is: an element that has no children elements and no text-node children, or an element that has a single text-node child, whose string value contains only whitespace characters.

    This XPath expression:

    //row[col[@name = 'POW']
                        [not(*)]
                           [not(normalize-space())]
          ]
    

    selects all row elements in the XML document, that have a col child, that has an attribute name with string value "POW" and that has no children – elements and whose string value consists either entirely of whitespace characters, or is the empty string.

    In case by “empty” you understand “having no children at all”, which means no children elements and no children PI nodes and no children comment nodes, then use:

    //row[col[@name = 'POW']
                        [not(node())]
          ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What Xpath expression can I use to find all the anchor (just 'a') elements
Can somebody help me find the mistake I am doing in evaluating following XPath
Guys, I'm trying to write xpath or css to find/click on list element All
I am currently trying the following xpath //tr[normalize-space(td/text())='User Name'] to get all the tr
I'm trying to use XPath to find all elements that have an element in
All of the examples I can find online about this involve simply adding content
I can find tutorials about mapping textures to polygons specifying vertices etc. but nothing
I can find lots of information on how Long Polling works (For example, this
I can find a direct table foreign key in c# like: foreach (ForeignKey key
How can find max of three numbers in XSL ? More Information : I

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.