472,341 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 software developers and data experts.

easy question - empty element?

In the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<Plcy service="ILiability" boId ="LifePolicy, 1">
<Prem service="IPremium" boId ="RegularPremium, 1"></Prem>
<L1 service="ILifeMain" type = "Life1">
<FirstName>Sheila</FirstName>
<Age>65</Age>
<Relation>spouse</Relation>
</L1>
<L2 service="ILife" type = "Life2">
<FirstName>Bruce</FirstName>
<Age>70</Age>
</L2>
</Plcy>

I would like to select Nodes with boId attribute which are empty. I am
using an XPath expression:

"//*[@boId and not(text())]"

but MS VS XPathNavigator's Select() returns both Plcy and Prem. It
also sets IsEmpty field of Prem node to false.

Whose fault is it - mine or MS?

Yours,

Valery the Newbie

Oct 30 '07 #1
5 3660
"Valery" <va*****@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
In the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<Plcy service="ILiability" boId ="LifePolicy, 1">
<Prem service="IPremium" boId ="RegularPremium, 1"></Prem>
<L1 service="ILifeMain" type = "Life1">
<FirstName>Sheila</FirstName>
<Age>65</Age>
<Relation>spouse</Relation>
</L1>
<L2 service="ILife" type = "Life2">
<FirstName>Bruce</FirstName>
<Age>70</Age>
</L2>
</Plcy>

I would like to select Nodes with boId attribute which are empty. I am
using an XPath expression:

"//*[@boId and not(text())]"

but MS VS XPathNavigator's Select() returns both Plcy and Prem. It
also sets IsEmpty field of Prem node to false.

Whose fault is it - mine or MS?

Yours,

Valery the Newbie
Maybe a whitespace issue. Try:
//*[@boId and not(normalize-space())]

--

Joe Fawcett (MVP - XML)

http://joe.fawcett.name
Oct 30 '07 #2
Valery wrote:
In the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<Plcy service="ILiability" boId ="LifePolicy, 1">
<Prem service="IPremium" boId ="RegularPremium, 1"></Prem>
<L1 service="ILifeMain" type = "Life1">
<FirstName>Sheila</FirstName>
<Age>65</Age>
<Relation>spouse</Relation>
</L1>
<L2 service="ILife" type = "Life2">
<FirstName>Bruce</FirstName>
<Age>70</Age>
</L2>
</Plcy>

I would like to select Nodes with boId attribute which are empty. I am
using an XPath expression:

"//*[@boId and not(text())]"
IN English that means "all elements having attribute bold and not having
at least one child text node". Plcy and Prem both satisfy this condition.
Try wider - select nodes that have no child nodes of any type at all:

"//*[@boId and not(node())]"

--
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog | http://www.XmlLab.Net
Oct 30 '07 #3
"Oleg Tkachenko [MVP]" <so**@body.comwrote in message
news:ea**************@TK2MSFTNGP04.phx.gbl...
Valery wrote:
>In the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<Plcy service="ILiability" boId ="LifePolicy, 1">
<Prem service="IPremium" boId ="RegularPremium, 1"></Prem>
<L1 service="ILifeMain" type = "Life1">
<FirstName>Sheila</FirstName>
<Age>65</Age>
<Relation>spouse</Relation>
</L1>
<L2 service="ILife" type = "Life2">
<FirstName>Bruce</FirstName>
<Age>70</Age>
</L2>
</Plcy>

I would like to select Nodes with boId attribute which are empty. I am
using an XPath expression:

"//*[@boId and not(text())]"

IN English that means "all elements having attribute bold and not having
at least one child text node". Plcy and Prem both satisfy this condition.
Try wider - select nodes that have no child nodes of any type at all:

"//*[@boId and not(node())]"

--
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog | http://www.XmlLab.Net
Prem appears to have no content.

--

Joe Fawcett (MVP - XML)

http://joe.fawcett.name
Oct 30 '07 #4
Joe Fawcett wrote:
"Oleg Tkachenko [MVP]" <so**@body.comwrote in message
news:ea**************@TK2MSFTNGP04.phx.gbl...
>Valery wrote:
>>In the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<Plcy service="ILiability" boId ="LifePolicy, 1">
<Prem service="IPremium" boId ="RegularPremium, 1"></Prem>
<L1 service="ILifeMain" type = "Life1">
<FirstName>Sheila</FirstName>
<Age>65</Age>
<Relation>spouse</Relation>
</L1>
<L2 service="ILife" type = "Life2">
<FirstName>Bruce</FirstName>
<Age>70</Age>
</L2>
</Plcy>

I would like to select Nodes with boId attribute which are empty. I am
using an XPath expression:

"//*[@boId and not(text())]"
IN English that means "all elements having attribute bold and not having
at least one child text node". Plcy and Prem both satisfy this condition.
Try wider - select nodes that have no child nodes of any type at all:

"//*[@boId and not(node())]"

--
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog | http://www.XmlLab.Net

Prem appears to have no content.
Yes, but it has end tag, so in XmlReader/XPathNavigator terms isn't
empty element:

XPathNavigator.IsEmptyElement Property

When overridden in a derived class, gets a value indicating whether the
current node is an empty element without an end element tag.

http://msdn2.microsoft.com/en-us/lib...tyelement.aspx

--
oleg
Oct 30 '07 #5
On Oct 31, 6:49 am, Oleg Tkachenko <f...@dummy.comwrote:
Joe Fawcett wrote:
"Oleg Tkachenko [MVP]" <s...@body.comwrote in message
news:ea**************@TK2MSFTNGP04.phx.gbl...
Valery wrote:
In the following XML:
><?xml version="1.0" encoding="utf-8" ?>
<Plcy service="ILiability" boId ="LifePolicy, 1">
<Prem service="IPremium" boId ="RegularPremium, 1"></Prem>
<L1 service="ILifeMain" type = "Life1">
<FirstName>Sheila</FirstName>
<Age>65</Age>
<Relation>spouse</Relation>
</L1>
<L2 service="ILife" type = "Life2">
<FirstName>Bruce</FirstName>
<Age>70</Age>
</L2>
</Plcy>
>I would like to select Nodes with boId attribute which are empty. I am
using an XPath expression:
> "//*[@boId and not(text())]"
IN English that means "all elements having attribute bold and not having
at least one child text node". Plcy and Prem both satisfy this condition.
Try wider - select nodes that have no child nodes of any type at all:
"//*[@boId and not(node())]"
--
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog|http://www.XmlLab.Net
Prem appears to have no content.

Yes, but it has end tag, so in XmlReader/XPathNavigator terms isn't
empty element:

XPathNavigator.IsEmptyElement Property

When overridden in a derived class, gets a value indicating whether the
current node is an empty element without an end element tag.

http://msdn2.microsoft.com/en-us/lib...th.xpathnaviga...

--
oleg- Hide quoted text -

- Show quoted text -
Wow (surprised) and thanks. It works indeed.
V.

Oct 30 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Derek Basch | last post by:
Hello All, I ran into a problem while dynamically constructing XHTML documents using minidom. If you create a script tag such as: ...
13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element...
13
by: vega | last post by:
How do I detect empty tags if I have the DOM document? For example: <br /> and <br></br> I tried org.w3c.dom.Node.getFirstChild(), it returns...
18
by: Neal | last post by:
According to the specs (http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element requires an end tag. And so, when we use <A...
3
by: Lukas | last post by:
title: xml to xml mapping: empty elements output although input element is not empty Why is is that when mapping from a XML schema to another...
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in...
1
by: tMan | last post by:
whats the xpath to get all the empty nodes in a document. in the xml below i want to get the nodes <empty> and <t> all other nodes either have a...
5
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is:...
7
by: kumar.senthil | last post by:
Hi, I'm using XmlSerializer to create an object from the XML string. I would like to know whether I can get a null value for an empty XML element....
3
by: Valery | last post by:
In the following XML: <?xml version="1.0" encoding="utf-8" ?> <Plcy service="ILiability" boId ="LifePolicy, 1"> <Prem service="IPremium" boId...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.