473,395 Members | 1,468 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,395 software developers and data experts.

XML Validator Revisited ?

Hello Gurus,

This is part of my XML File.

<Group ID="100">
<Name>Dotnet XML</Name>
<Member ID="BA1908">Guru Bhai</Member>
</Group>

When I validate this xml against a schema using XmlValidatingReader and
when I get a error in the ID attribute of the Node Group, How can I get
the Node or _FullName of that attribute.

I cannot access _FullName which gives me the node name which is
"Group", I get this error

'System.Xml.XmlValidatingReader._FullName' is inaccessible due to its
protection level

Is there a way I can get the Node Name to which the attribute belongs
to.

Thanks,
Shailendra Batham

Nov 12 '05 #1
3 1229
batham wrote:
<Group ID="100">
<Name>Dotnet XML</Name>
<Member ID="BA1908">Guru Bhai</Member>
</Group>

When I validate this xml against a schema using XmlValidatingReader and
when I get a error in the ID attribute of the Node Group, How can I get
the Node or _FullName of that attribute.
XmlValidatingReader doesn't expose nodes. And you can get name of the
node it's positioned it via Name property.
I cannot access _FullName which gives me the node name which is
"Group", I get this error


Sure. It's private field.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
I know I can get the node name, but my problem is I want the parent
node

for eg.

if this was my XML file

<Books id="ab1"></Books>

and my schema validated this saying the ID is wrong which is a
attribute of BOOKS....... so when I get the error using
XmlValidatingReader, somehow I would like to know that the parent node
is BOOKS, which is stored in _FullName.

Thanks,
Shailendra Batham

Nov 12 '05 #3
If you want the element name while validating attributes store the name
before the first call to MoveToNextAttribute()
XmlValidatingReader valReader = new XmlValidatingReader(new
XmlTextReader("myxml.xml"));
while(valReader.Read()) {
if(valReader.NodeType == XmlNodeType.Element) {
string parentElementName = valReader.Name;
ProcessAttributes(parentElementName, valReader);
}
}

You can also call MoveToElement() when you encounter an error on an
attribute node and then get valReader.Name, but in this case you will have
maintain the postition of the attribute you are processing so that after
getting the element name, you have to reposition yourself on the same
attribute.

Thanks,
Priya

string parentElementName = val
"batham" <ba****@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
I know I can get the node name, but my problem is I want the parent
node

for eg.

if this was my XML file

<Books id="ab1"></Books>

and my schema validated this saying the ID is wrong which is a
attribute of BOOKS....... so when I get the error using
XmlValidatingReader, somehow I would like to know that the parent node
is BOOKS, which is stored in _FullName.

Thanks,
Shailendra Batham

Nov 12 '05 #4

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

Similar topics

195
by: Torbjørn Pettersen | last post by:
As you might have noticed I'm trying to clean up my web site's HTML code. The way I do it is simply more or less redoing to complete site, testing it on a web server I have set up on my local...
0
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
5
by: sandman | last post by:
I've been testing my web app on another workstation to simulate using the server time. The test pc's time is an hour behind the server time and when the user processes a request, the server time...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
40
by: VK | last post by:
Hi, After the response on my request from W3C I'm still unclear about Tidy vs. Validator discrepansies. That started with <IFRAME> issue, but there is more as I know. Anyway, this very basic...
2
by: Mike Collins | last post by:
I have a form where I create dynamic controls at runtime. With this, I am adding a dynamic required field validator to each control as needed, but the validators are not firing when I click submit....
6
by: yaru22 | last post by:
I'd like to create a program that validates bunch of urls against the w3c markup validator (http://validator.w3.org/) and store the result in a file. Since I don't know network programming, I...
1
by: Gonza | last post by:
Hi group, i'm trying to add a customvalidator control to a custom web control. The problem is i'm getting a "Unable to find control id..." exception. Here is the code: public class CuitTextBox :...
9
by: Daniele Perilli | last post by:
Hi everybody, I'd like to introduce you a new little tool I developed to automatically check markup validation of all pages in given websites. It uses W3C HTML Validator and CSS Validator online...
37
by: Prisoner at War | last post by:
Actually, it doesn't have to be a blockquote...but I'm at my wits' end: I want to make bold several lines of text which have a pair of <br /tags between them...seems like the <b></bdo not "carry...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.