473,395 Members | 1,631 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.

Data types for XmlElement and XmlAttribute

Roy
I have an XmlDocument loaded from an xml file. I have also an xsd schema file
associated with it so that it will be in the XmlSchemaSet.
How do I get the data type for the value of an XmlElement and XmlAttribute
as described in the schema while I am accessing the nodes (attributes and
element) in the XmlDocument?
Jul 18 '06 #1
3 5081


Roy wrote:
I have an XmlDocument loaded from an xml file. I have also an xsd schema file
associated with it so that it will be in the XmlSchemaSet.
How do I get the data type for the value of an XmlElement and XmlAttribute
as described in the schema while I am accessing the nodes (attributes and
element) in the XmlDocument?
That is possible in .NET 2.0, see the property SchemaInfo
<http://msdn2.microsoft.com/en-us/library/system.xml.xmlelement.schemainfo.aspx>
<http://msdn2.microsoft.com/en-us/library/system.xml.schema.ixmlschemainfo.aspx>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 18 '06 #2
Roy
Is there any support in .Net to get the value (for both attribute and
element) in its defined types?
The value for XmlAttribute alway gives a string for example. If it is
defined as an interger in xsd, I would like to get it as an interger. Or I
have to write my code to convert it for every types from string.

"Martin Honnen" wrote:
>

Roy wrote:
I have an XmlDocument loaded from an xml file. I have also an xsd schema file
associated with it so that it will be in the XmlSchemaSet.
How do I get the data type for the value of an XmlElement and XmlAttribute
as described in the schema while I am accessing the nodes (attributes and
element) in the XmlDocument?

That is possible in .NET 2.0, see the property SchemaInfo
<http://msdn2.microsoft.com/en-us/library/system.xml.xmlelement.schemainfo.aspx>
<http://msdn2.microsoft.com/en-us/library/system.xml.schema.ixmlschemainfo.aspx>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 18 '06 #3
If you use an XPathNavigator over the XmlDocument, then you can get typed
values (typed according to the schema) using the following properties on the
navigator:
TypedValue Property
ValueAsBoolean Property
ValueAsDateTime Property
ValueAsDouble Property
ValueAsInt Property
ValueAsLong Property

Thanks,
Priya

"Roy" <Ro*@discussions.microsoft.comwrote in message
news:5F**********************************@microsof t.com...
Is there any support in .Net to get the value (for both attribute and
element) in its defined types?
The value for XmlAttribute alway gives a string for example. If it is
defined as an interger in xsd, I would like to get it as an interger. Or I
have to write my code to convert it for every types from string.

"Martin Honnen" wrote:
>>

Roy wrote:
I have an XmlDocument loaded from an xml file. I have also an xsd
schema file
associated with it so that it will be in the XmlSchemaSet.
How do I get the data type for the value of an XmlElement and
XmlAttribute
as described in the schema while I am accessing the nodes (attributes
and
element) in the XmlDocument?

That is possible in .NET 2.0, see the property SchemaInfo
<http://msdn2.microsoft.com/en-us/library/system.xml.xmlelement.schemainfo.aspx>
<http://msdn2.microsoft.com/en-us/library/system.xml.schema.ixmlschemainfo.aspx>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Jul 18 '06 #4

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

Similar topics

3
by: Anita C | last post by:
I have the foll. code to update the value of an attribute: xmlDocument.Load("abc.xml"); XmlAttribute xmlAttrib = xmlDocument.SelectSingleNode(root/web/theme/@desc); xmlAttrib.Value =...
5
by: Michel | last post by:
Hi there, What is the best way to serialize unknown data? I have a class that contains a list of parameter objects. The parameter has a value which can be a simple value of a complex class,...
1
by: nibble | last post by:
I'm doign the following: XmlElement myElem....; string name = "xmlns:"+"abc"; string value = "http://www.abc.com"; myElem.SetAttribute(name, value); I get an exception saying that name...
3
by: Rich Wallace | last post by:
Hi all, I've been though many posts in this group and have yet to find one that helps me understand how to accomplish my goal. I have an XML document that stores user specific values that I...
7
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i donīt want to filter the return value of the method, i have to pass a new instance of the...
3
by: Paulo Morgado [MVP] | last post by:
Hi all ..NET Framework 1.1 I have created several types that are serailized to XML as strings. Someting like this: public struct MyInt32 : IXmlSerializable { int value;
2
by: irishdudeinusa | last post by:
Hello Everyone, I have been working a webservice where I can use it in other applications that I am working on. However, I am running into a problem with the data returned and I was wondering if...
2
by: =?Utf-8?B?Sm9uIEphY29icw==?= | last post by:
XmlElement has an attributes collection (called Attriburtes) Attribures has an Append method to which you pass a node XmlNode mustinherit, so I can't create that. XMLAttribute New is protected,...
2
by: nygiantswin2005 | last post by:
Hi I have wrote a method in my C# class with the following code, to create an XMl file. The root element is suppose to have 3 attibutes. I can not get attributes to appear correctly. ...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.