HighTechTalks DotNet Forums  

How to Parse Tables in XML

Dotnet XML microsoft.public.dotnet.xml


Discuss How to Parse Tables in XML in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
JeffP->
 
Posts: n/a

Default How to Parse Tables in XML - 04-22-2010 , 10:18 AM






New to XML, I'm using ds.ReadXML(sFilePath) in my XMLHelper as dataset

In my test page I'm adding a table to the ds XMLTables, cols TableName &
ChildNode, then for each dt in ds.tables rows.add(dt.tablename...

But, my tables are not what I would expect; for example, in the following
excerpt...

<?xml version="1.0" encoding="utf-8" ?>
- <TXLife xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ACORD.org/Standards/Life/2"
xsi:schemaLocation="http://ACORD.org/Standards/Life/2 TXLife2.19.00enum.xsd">
- <UserAuthRequest>
<UserLoginName>MeHo</UserLoginName>
- <UserPswd>
<CryptType>NONE</CryptType>
<Pswd>MH2010</Pswd>
</UserPswd>
- <VendorApp>
<VendorName VendorCode="000">Partner Company</VendorName>
<AppName>SuperSystem</AppName>
<AppVer>1.0.1</AppVer>
</VendorApp>
</UserAuthRequest>
- <TXLifeRequest>
<TransRefGUID>7e21f6bd-0d7c-4a7f-b20a-bb84a69f187e</TransRefGUID>
<TransType tc="121">Order Request</TransType>
<TransExeDate>2010-04-20</TransExeDate>
<TransExeTime>17:59:02.6321632-07:00</TransExeTime>
<TestIndicator tc="0">True</TestIndicator>
- <OLifE>
......

I expect a table named - <UserAuthRequest> but not another - <UserPswd>
I would like a table UserAuthRequest, with cols...
Col1 UserLoginName
Col2 UserPassWord
Col3 CryptType
Col4 Pswd

I would expect that there is an easy way to specify how the XML is parsed
into tables, perhaps during the read XML?

Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: How to Parse Tables in XML - 04-22-2010 , 10:28 AM






JeffP-> wrote:

Quote:
I would expect that there is an easy way to specify how the XML is parsed
into tables, perhaps during the read XML?
Basically any element with child elements or attributes is mapped to a
table and leaf element and attributes serve as columns of tables in the
schema respectively as values of rows in the data.

You can define an XML schema for the mapping and read that in with
ReadXmlSchema() before doing ReadXml() but that is not going to complete
change the table and relation structure, it is more aimed at defining
the simple types for leaf element and for attributes (e.g. whether
<foo>2</foo> is treated as a column with string content, int content or
double content).

See http://msdn.microsoft.com/en-us/library/bfdchewb(v=VS.90).aspx or
the corresponing section in your local MSDN library installation for
details.


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/

Reply With Quote
  #3  
Old   
JeffP->
 
Posts: n/a

Default Re: How to Parse Tables in XML - 04-22-2010 , 11:21 AM



Martin, thanks for your post.

I really shouldn't have used "expected", I see why the userPswd is another
table, I should've said, "wanted". Anyway, I really don't need the ability to
have distinct tables. I'm planning on using/reading an XML template, then
update only certain contents of my XML before sending it on as a unique
order, but I thought it would be useful later in my project.

"Martin Honnen" wrote:

Quote:
JeffP-> wrote:

I would expect that there is an easy way to specify how the XML is parsed
into tables, perhaps during the read XML?

Basically any element with child elements or attributes is mapped to a
table and leaf element and attributes serve as columns of tables in the
schema respectively as values of rows in the data.

You can define an XML schema for the mapping and read that in with
ReadXmlSchema() before doing ReadXml() but that is not going to complete
change the table and relation structure, it is more aimed at defining
the simple types for leaf element and for attributes (e.g. whether
foo>2</foo> is treated as a column with string content, int content or
double content).

See http://msdn.microsoft.com/en-us/library/bfdchewb(v=VS.90).aspx or
the corresponing section in your local MSDN library installation for
details.


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.