469,609 Members | 1,795 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

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 1120
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Randy | last post: by
2 posts views Thread by pei_world | last post: by
3 posts views Thread by Danky | last post: by
4 posts views Thread by Jan Nielsen | last post: by
13 posts views Thread by pmcguire | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.