473,394 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Can't aquire element's value if it hosts sub-elements

As the title say, I can't aquire element's value if it hosts
sub-elements.

Let me explain - My XML looks like this:-
<a>
<infill>xxxxxx</infill>
<SourceEndPoint>testdata
<EndPoint>
<AliasRef ref="lAlias120001">
<Qualifier><![CDATA[OrganizationName]]></Qualifier>
<Value><![CDATA[Home Organization]]></Value>
</AliasRef>
<OrgName ref="lOrg110001"><![CDATA[Home
Organization]]></OrgName>
</EndPoint>
</SourceEndPoint>
</a>
When "pointing" to element <SourceEndPoint> via MoveToNext method the
Value property is set to:
"OrganizationNameHome OrganizationHome Organization"
Which is correct - A concatenation of child node values.

I want the data associated with <SourceEndPoint> element (i.e.
"testdata")

Can someone help? (Bear in mind that moving to parent then means your
first child is <infill> element)

Dan

Nov 30 '05 #1
2 1091
DesperateDan wrote:
As the title say, I can't aquire element's value if it hosts
sub-elements.

Let me explain - My XML looks like this:-
<a>
<infill>xxxxxx</infill>
<SourceEndPoint>testdata
<EndPoint>


This is usually A Very Bad Idea in non-text documents. It's called Mixed
Content, and it means the content of the SourceEndPoint element is made
up of both text (testdata) *and* other elements (EndPoint). This is the
normal usage in text documents (eg HTML paragraphs, where you can mix
text and subelements) but it's almost always a poor design decision in
"data" documents. It would be easier to say

<SourceEndPoint>
<Data>testdata</Data>
<EndPoint>
...

If you absolutely can't change the markup (eg it's been sicced on you
by someone who doesn't understand XML) then the text content can be
accessed as the first text-node in the SourceEndPoint element. In XSLT
this would be the XPath expression SourceEndPoint/text()[1] (and bear
in mind that the returned value will include the newline after the text
*and* the following spaces up to the start of <EndPoint>: this is one
of the reasons why allowing unmarked data to float around the place not
properly identified is not good design).

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Nov 30 '05 #2
> When "pointing" to element <SourceEndPoint> via MoveToNext method the
Value property is set to:
"OrganizationNameHome OrganizationHome Organization"
Which is correct - A concatenation of child node values.

I want the data associated with <SourceEndPoint> element (i.e.
"testdata")

Can someone help? (Bear in mind that moving to parent then means your
first child is <infill> element)

I suggest you try the following:
When "pointing" to element <SourceEndPoint>, you call Read() again to
move to the first child text element, then get its value.

Thi

Dec 1 '05 #3

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

Similar topics

0
by: David Swanson | last post by:
I am trying to configure the proxy section of the machine.config to handle BOTH connecting to hosts that are not "live" but rather defined in my winnt/system32/drivers/etc/hosts file. AND to hosts...
2
by: Tarren | last post by:
Hi: The problem I am having is when I validate an xml file to a schema, it is erroring out every element. I think this has something to do with me defining/referencing the namespaces. I have...
3
by: Fan Ruo Xin | last post by:
I ran the runstats and try to collect sub-element statistics, but for some reason, the value of that two fields in syscat.columns is always -1. Does anyone have any idea?
7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
0
by: Joel Turner | last post by:
I have set up a web site which connects to a web service to authenitcate the site when the application state starts. I am using WSE 1.0 using the CustomBinaryToken as per the example in WSE 1.0 to...
3
by: Bob Clegg | last post by:
I am in the same boat as Moondog on the 2nd July. I have a report designed against a dataset. Proved the datasset is OK by dropping a datagrid onto the form and it binds OK to the data. But the...
5
by: Just Me | last post by:
Given a button name Btn_5 and Index=5 I want to do something like dim zz as string = Btn_??Index??.Text or given an array of buttons, do:
6
by: Julien | last post by:
Hello, I have some files located in a file server and managed by a SQL database from a web based interface using ASP + VBSCRIPT technology. I need to automatically copy those files to a web...
1
by: shapper | last post by:
Hello, I am trying to convert an Asp.Net XML sitemap file in a Google XMl sitemap file using a XSL file using an HttpHandler. Everything seems well in my code but I am getting an error: XML...
11
by: jyck91 | last post by:
// Base Conversion // Aim: This program is to convert an inputted number // from base M into base N. Display the converted // number in base N. #include <stdio.h> #include <stdlib.h>...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.