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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:48:23+00:00 2026-06-17T18:48:23+00:00

In an XML document such as: <a> <b> <c>Text1</c> … </b> <b> <c>Text2</c> …

  • 0

In an XML document such as:

<a>
  <b>
    <c>Text1</c>
    ...
  </b>
  <b>
    <c>Text2</c>
    ...
  </b>
  ...
</a>

What is a single XPath 1.0-compatible, local-namespace()-compatible, expression to return a Null set if any element contains the inner text of ‘Text1’.

I have tried numerous different expressions and cannot get elements that would return a null set.

e.g.

//*[local-name()='c' and .='Text1']

- or -   

/*[local-name()='a']/*[local-name()='b']/*not(local-name()='c' and .='Text1'])

The stringent requirements are due to a specific implementation of the .NET function call XmlNode.SelectSingleNode Method (String)

Final exact solution
Courtesy Dimitre

/*[not(//*[local-name()='c' and . = 'Text1'])]
  • 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-17T18:48:24+00:00Added an answer on June 17, 2026 at 6:48 pm

    What is a single XPath 1.0-compatible, local-namespace()-compatible,
    expression to return a Null set if any element contains the inner text
    of ‘Text1’.

    You haven’t specified what should be selected if there is no such c element, so below I select in this case the top element.

    Use:

    /*[not(//c[. = 'Text1'])]
    

    This would select nothing in case there is a c element in the XML document, whose string value is “Text1”.

    In case of using default namespace, this would be written as:

    /*[not(//*[name()='c' and . = 'Text1'])]
    

    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:strip-space elements="*"/>
    
     <xsl:template match="/">
         <xsl:copy-of select="/*[not(//c[. = 'Text1'])]"/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <a>
      <b>
        <c>Text1</c>
        ...
      </b>
      <b>
        <c>Text2</c>
        ...
      </b>
      ...
    </a>
    

    the XPath expression is evaluated and the result of this evaluation is copied to the output — in this case nothing is produced — as expected.

    If we change the above XML document to:

    <a>
      <b>
        <c>Text3</c>
        ...
      </b>
      <b>
        <c>Text2</c>
        ...
      </b>
      ...
    </a>
    

    then the condition is true() and the result of the evaluation is the subtree rooted by the top element:

    <a>
        <b>
            <c>Text3</c>
        ...
        </b>
        <b>
            <c>Text2</c>
        ...
        </b>
      ...
    </a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My XML document looks like this When I run XPATH query //collected_objects , I
I have a file that has many xml-like elements such as this one: <document
Given an XML document such as this: <root> <foo> <bar>a</bar> <bar>b</bar> <bar>c</bar> </foo> ...
How to extract the text of such an element via XPath: <document> some text
In Flex, I have an xml document such as the following: var xml:XML =
Is it possible to serialize xml document in C# to produce such tags ...
What characters must be escaped in XML documents, or where could I find such
XML document: <?xml version=1.0 encoding=UTF-8?> <ProcessData> <SOAPAction>urn:echo</SOAPAction> <Content_Type>text/xml;charset=UTF-8</Content_Type> <uname>sarah_brcm</uname> <pwd>BRCM_UVLwNhjrA5fbgqkUNdxQXMfcCDJ</pwd> </ProcessData> XSLT: <?xml version=1.0
My XML document looks like this- <doc> <system_data> <registry_item id=1> <hive>HKEY_LOCAL_MACHINE</hive> </registry_item> <file_item id=2>
I have the following XML Document: <?xml version=\1.0\ encoding=\UTF-8\?> <atom:entry xmlns:atom=\http://www.w3.org/2005/Atom\ xmlns:apps=\http://schemas.google.com/apps/2006\ xmlns:gd=\http://schemas.google.com/g/2005\> <apps:property

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.