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

XML 2 Datagrid Question

I am databinding a grid to an XML source (given below).

I am displaying the grid contents inside an
TemplateColumn/ItemTemplate using regular <%#
DataBinder.Eval(Container.DataItem, "Net-Change-Price") %> tags.

My question is:
How can I access/display the attributes of an XML node. More
specifically in the current example, how can I access/display 'symbol'
attribute in the 'equity-quote' node?

Thanks in advance.
Databinding code:
-------
MyStocksDataSet.ReadXml(http://quotes.nasdaq.com/quote.dll?m...l&symbol=BAESF)
MyStocksDataGrid.DataSource = MyStocksDataSet
MyStocksDataGrid.DataBind()

XML
------
<?xml version="1.0" ?>
<nasdaqamex-dot-com>
<equity-quote symbol="BAESF" ilx-symbol="BAESF"
hyperfeed-symbol="BAESF" telesphere-symbol="BAESF" cusip="G1489618">
<issue-name>BAES SYSTEMS PLC</issue-name>
<market-status>O</market-status>
<market-center-code>Other OTC</market-center-code>
<issue-type-code>Foreign Issue</issue-type-code>
<todays-high-price>0</todays-high-price>
<todays-low-price>0</todays-low-price>
<fifty-two-wk-high-price>3.2</fifty-two-wk-high-price>
<fifty-two-wk-low-price>1.75</fifty-two-wk-low-price>
<last-sale-price>2.925</last-sale-price>
<net-change-price>unch</net-change-price>
<net-change-pct>unch</net-change-pct>
<share-volume-qty>0</share-volume-qty>
<previous-close-price>2.925</previous-close-price>
<current-pe-ratio>N/A</current-pe-ratio>
<total-outstanding-shares-qty>0</total-outstanding-shares-qty>
<current-yield-pct>0.000000</current-yield-pct>
<earnings-actual-eps-amt>0</earnings-actual-eps-amt>
<cash-dividend-amt>0</cash-dividend-amt>
<cash-dividend-ex-date>19691231</cash-dividend-ex-date>
<sp500-beta-num>0.200000</sp500-beta-num>
<trade-datetime>20031217 10:17:24</trade-datetime>
<trading-status>ACTIVE</trading-status>
<market-capitalization-amt>0</market-capitalization-amt>
<option-root-symbol symbol="" />
</equity-quote>
</nasdaqamex-dot-com>
Nov 18 '05 #1
3 1201
One way might be as follows.
The DataBinder.Eval accepts a third argument which is a format command. for
example "{0,c}" is for currency format (the 0 is always 0) and the c is for
currency. One problem though is that the format must be of the date type of
the data defined by the XML schema or by the data type of the column if you
have added columns to you data. If you don't have a schema file all xml
values are considered strings and the format argument will not help for
numbers. If you want to create the schema, in my experience (which is not a
lot) the best way to get a running start on the schema file is to load the
xml file to a data set and infer schema (ds.ReadXml(yourXMLPathandFile,
XmlReadMode.InferSchema) and then save it with schema
(ds.writeXML(strXMLPathandFile, XmlWriteMode.WriteSchema) Then you can
change the data types etc.
Hope this helps.

"Raghuvansh" <ra********@yahoo.com> wrote in message
news:39**************************@posting.google.c om...
I am databinding a grid to an XML source (given below).

I am displaying the grid contents inside an
TemplateColumn/ItemTemplate using regular <%#
DataBinder.Eval(Container.DataItem, "Net-Change-Price") %> tags.

My question is:
How can I access/display the attributes of an XML node. More
specifically in the current example, how can I access/display 'symbol'
attribute in the 'equity-quote' node?

Thanks in advance.
Databinding code:
-------
MyStocksDataSet.ReadXml(http://quotes.nasdaq.com/quote.dll?mode=stock&page=x
ml&symbol=BAESF) MyStocksDataGrid.DataSource = MyStocksDataSet
MyStocksDataGrid.DataBind()

XML
------
<?xml version="1.0" ?>
<nasdaqamex-dot-com>
<equity-quote symbol="BAESF" ilx-symbol="BAESF"
hyperfeed-symbol="BAESF" telesphere-symbol="BAESF" cusip="G1489618">
<issue-name>BAES SYSTEMS PLC</issue-name>
<market-status>O</market-status>
<market-center-code>Other OTC</market-center-code>
<issue-type-code>Foreign Issue</issue-type-code>
<todays-high-price>0</todays-high-price>
<todays-low-price>0</todays-low-price>
<fifty-two-wk-high-price>3.2</fifty-two-wk-high-price>
<fifty-two-wk-low-price>1.75</fifty-two-wk-low-price>
<last-sale-price>2.925</last-sale-price>
<net-change-price>unch</net-change-price>
<net-change-pct>unch</net-change-pct>
<share-volume-qty>0</share-volume-qty>
<previous-close-price>2.925</previous-close-price>
<current-pe-ratio>N/A</current-pe-ratio>
<total-outstanding-shares-qty>0</total-outstanding-shares-qty>
<current-yield-pct>0.000000</current-yield-pct>
<earnings-actual-eps-amt>0</earnings-actual-eps-amt>
<cash-dividend-amt>0</cash-dividend-amt>
<cash-dividend-ex-date>19691231</cash-dividend-ex-date>
<sp500-beta-num>0.200000</sp500-beta-num>
<trade-datetime>20031217 10:17:24</trade-datetime>
<trading-status>ACTIVE</trading-status>
<market-capitalization-amt>0</market-capitalization-amt>
<option-root-symbol symbol="" />
</equity-quote>
</nasdaqamex-dot-com>

Nov 18 '05 #2
One minor error, the "{0,c}" should read "{0;c}" as an example.
"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:br**********@ngspool-d02.news.aol.com...
One way might be as follows.
The DataBinder.Eval accepts a third argument which is a format command. for example "{0,c}" is for currency format (the 0 is always 0) and the c is for currency. One problem though is that the format must be of the date type of the data defined by the XML schema or by the data type of the column if you have added columns to you data. If you don't have a schema file all xml
values are considered strings and the format argument will not help for
numbers. If you want to create the schema, in my experience (which is not a lot) the best way to get a running start on the schema file is to load the
xml file to a data set and infer schema (ds.ReadXml(yourXMLPathandFile,
XmlReadMode.InferSchema) and then save it with schema
(ds.writeXML(strXMLPathandFile, XmlWriteMode.WriteSchema) Then you can
change the data types etc.
Hope this helps.

"Raghuvansh" <ra********@yahoo.com> wrote in message
news:39**************************@posting.google.c om...
I am databinding a grid to an XML source (given below).

I am displaying the grid contents inside an
TemplateColumn/ItemTemplate using regular <%#
DataBinder.Eval(Container.DataItem, "Net-Change-Price") %> tags.

My question is:
How can I access/display the attributes of an XML node. More
specifically in the current example, how can I access/display 'symbol'
attribute in the 'equity-quote' node?

Thanks in advance.
Databinding code:
-------

MyStocksDataSet.ReadXml(http://quotes.nasdaq.com/quote.dll?mode=stock&page=x ml&symbol=BAESF)
MyStocksDataGrid.DataSource = MyStocksDataSet
MyStocksDataGrid.DataBind()

XML
------
<?xml version="1.0" ?>
<nasdaqamex-dot-com>
<equity-quote symbol="BAESF" ilx-symbol="BAESF"
hyperfeed-symbol="BAESF" telesphere-symbol="BAESF" cusip="G1489618">
<issue-name>BAES SYSTEMS PLC</issue-name>
<market-status>O</market-status>
<market-center-code>Other OTC</market-center-code>
<issue-type-code>Foreign Issue</issue-type-code>
<todays-high-price>0</todays-high-price>
<todays-low-price>0</todays-low-price>
<fifty-two-wk-high-price>3.2</fifty-two-wk-high-price>
<fifty-two-wk-low-price>1.75</fifty-two-wk-low-price>
<last-sale-price>2.925</last-sale-price>
<net-change-price>unch</net-change-price>
<net-change-pct>unch</net-change-pct>
<share-volume-qty>0</share-volume-qty>
<previous-close-price>2.925</previous-close-price>
<current-pe-ratio>N/A</current-pe-ratio>
<total-outstanding-shares-qty>0</total-outstanding-shares-qty>
<current-yield-pct>0.000000</current-yield-pct>
<earnings-actual-eps-amt>0</earnings-actual-eps-amt>
<cash-dividend-amt>0</cash-dividend-amt>
<cash-dividend-ex-date>19691231</cash-dividend-ex-date>
<sp500-beta-num>0.200000</sp500-beta-num>
<trade-datetime>20031217 10:17:24</trade-datetime>
<trading-status>ACTIVE</trading-status>
<market-capitalization-amt>0</market-capitalization-amt>
<option-root-symbol symbol="" />
</equity-quote>
</nasdaqamex-dot-com>


Nov 18 '05 #3
McP
Anyone else having a problem with that nasdaq url? It used to work
until around Dec. 18. Now the resulting xml has no data in it, but
the other page types (like multi) work fine.

"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message news:<br**********@ngspool-d02.news.aol.com>...
One minor error, the "{0,c}" should read "{0;c}" as an example.
"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:br**********@ngspool-d02.news.aol.com...
One way might be as follows.
The DataBinder.Eval accepts a third argument which is a format command.

for
example "{0,c}" is for currency format (the 0 is always 0) and the c is

for
currency. One problem though is that the format must be of the date type

of
the data defined by the XML schema or by the data type of the column if

you
have added columns to you data. If you don't have a schema file all xml
values are considered strings and the format argument will not help for
numbers. If you want to create the schema, in my experience (which is not

a
lot) the best way to get a running start on the schema file is to load the
xml file to a data set and infer schema (ds.ReadXml(yourXMLPathandFile,
XmlReadMode.InferSchema) and then save it with schema
(ds.writeXML(strXMLPathandFile, XmlWriteMode.WriteSchema) Then you can
change the data types etc.
Hope this helps.

"Raghuvansh" <ra********@yahoo.com> wrote in message
news:39**************************@posting.google.c om...
I am databinding a grid to an XML source (given below).

I am displaying the grid contents inside an
TemplateColumn/ItemTemplate using regular <%#
DataBinder.Eval(Container.DataItem, "Net-Change-Price") %> tags.

My question is:
How can I access/display the attributes of an XML node. More
specifically in the current example, how can I access/display 'symbol'
attribute in the 'equity-quote' node?

Thanks in advance.
Databinding code:
-------

MyStocksDataSet.ReadXml(http://quotes.nasdaq.com/quote.dll?mode=stock&page=x
ml&symbol=BAESF)
MyStocksDataGrid.DataSource = MyStocksDataSet
MyStocksDataGrid.DataBind()

XML
------
<?xml version="1.0" ?>
<nasdaqamex-dot-com>
<equity-quote symbol="BAESF" ilx-symbol="BAESF"
hyperfeed-symbol="BAESF" telesphere-symbol="BAESF" cusip="G1489618">
<issue-name>BAES SYSTEMS PLC</issue-name>
<market-status>O</market-status>
<market-center-code>Other OTC</market-center-code>
<issue-type-code>Foreign Issue</issue-type-code>
<todays-high-price>0</todays-high-price>
<todays-low-price>0</todays-low-price>
<fifty-two-wk-high-price>3.2</fifty-two-wk-high-price>
<fifty-two-wk-low-price>1.75</fifty-two-wk-low-price>
<last-sale-price>2.925</last-sale-price>
<net-change-price>unch</net-change-price>
<net-change-pct>unch</net-change-pct>
<share-volume-qty>0</share-volume-qty>
<previous-close-price>2.925</previous-close-price>
<current-pe-ratio>N/A</current-pe-ratio>
<total-outstanding-shares-qty>0</total-outstanding-shares-qty>
<current-yield-pct>0.000000</current-yield-pct>
<earnings-actual-eps-amt>0</earnings-actual-eps-amt>
<cash-dividend-amt>0</cash-dividend-amt>
<cash-dividend-ex-date>19691231</cash-dividend-ex-date>
<sp500-beta-num>0.200000</sp500-beta-num>
<trade-datetime>20031217 10:17:24</trade-datetime>
<trading-status>ACTIVE</trading-status>
<market-capitalization-amt>0</market-capitalization-amt>
<option-root-symbol symbol="" />
</equity-quote>
</nasdaqamex-dot-com>


Nov 18 '05 #4

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

Similar topics

2
by: magister | last post by:
Hello, I have xml like this.... <test> <question>sdfsa</question> <section><question>43ga</question> <question>asdf</question> </test>
0
by: Randy | last post by:
Hello, I have two questions... I have a datagrid. I'm capturing the cell via HitTestInfo. The first question is fairly simple. I'm using an example of how to capture the row/column I found on the...
3
by: BBFrost | last post by:
Ok, I know how to count the number of selected datagrid rows using the code below. What has me stumped is how to determine when the selected rows within a datagrid have been changed. The...
6
by: BBFrost | last post by:
I'm using Net 1.1 (2003) SP1 & Windows 2000 Here's the issue ... Rows 12 thru 24 are selected in a datagrid. The user now unselects rows 12 thru 24 and selects rows 45 thru 70 ??? How can...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
2
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last,...
3
by: Danky | last post by:
Hello Masters! Anyone can help me with the datagrid, well, the app load a lot of data from DB and it show on the datagrid, and well, I need to allow paging and.... the issue is with the event...
4
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
13
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.