Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: ASP.NET 2- Can't read data in XML file

From: "noone" <noone@-------.--->
To: NULL
Date: 4/3/2006 7:07:00 PM

Hi Martin,
YES works like charm. Thanks
I have another question-
What do I have to do to enable Add, Delete, update functionality to the site 
I created with VWD.
The buttons are there for Update an Deleting but they don't work, also how 
do I Add to the XML file.

Thanks once again


"noone" <noone@n...> wrote in message 
news:O9Hmgl2VGHA.5036@T......
> Thanks Martin, I will give this a try and let you know.
> Thanks again!
> "Martin Honnen" <mahotrash@y...> wrote in message 
> news:OAuOdrxVGHA.2208@T......
>>
>>
>> noone wrote:
>>
>>
>>> I've seen many complaints about the exact some thing I'm seeing.
>>> It appears that the XML file has to have attributes or it wont work 
>>> using the VWD and using Xmldatasource and Gridview objects.
>>> I'd say it's bug, I'd find it hard to believe that this is by design.
>>
>> You can then first run an XSLT transformation on the original XML to 
>> convert child elements to attributes for instance. The XmlDataSource has 
>> members to allow that.
>>
>> Here is a simple example that works for me with ASP.NET 2.0:
>>
>> XML file test2006040201.xml is for instance
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <gods>
>>   <god>
>>     <name>Kibo</name>
>>     <power>42</power>
>>   </god>
>>   <god>
>>     <name>Xibo</name>
>>     <power>-42</power>
>>   </god>
>> </gods>
>>
>> where the god elements are the records to be displayed within the table 
>> and the child elements name and power the columns.
>>
>> Then I have written a generic XSLT stylesheet (e.g. 
>> test2006040301Xsl.xml) that transforms the leaf child elements (e.g. name 
>> and power) to attributes:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet
>>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>   version="1.0">
>>
>> <xsl:output method="xml"  />
>>
>> <xsl:template match="@* | node()">
>>   <xsl:copy>
>>     <xsl:apply-templates select="@* | node()" />
>>   </xsl:copy>
>> </xsl:template>
>>
>> <xsl:template match="*[*[not(*)]]">
>>   <xsl:copy>
>>     <xsl:apply-templates select="*" mode="element-to-attribute" />
>>   </xsl:copy>
>> </xsl:template>
>>
>> <xsl:template match="*" mode="element-to-attribute">
>>   <xsl:attribute name="{name()}"><xsl:value-of select="." 
>> /></xsl:attribute>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>>
>>
>> You could then apply that in an ASP.NET page as follows:
>>
>> <form runat="server">
>> <asp:XmlDataSource
>>   id="godSource1"
>>   runat="server"
>>   DataFile="test2006040201.xml"
>>   TransformFile="test2006040301Xsl.xml"
>>   XPath="gods/god" />
>>
>>
>> <asp:GridView
>>   id="GridView1"
>>   DataSourceID="godSource1"
>>   runat="server">
>> </asp:GridView>
>>
>> </form>
>>
>> Let us now whether that helps. As said the stylesheet is generic so it 
>> hopefully works with your original XML
>>
>> <?xml version="1.0" standalone="yes"?>
>> <webstats>
>> <app>
>> <dir>\\w3svc72802400\\</dir>
>> <dns>Fbot</dns>
>> <nbserver>\\fiscmmk410win</nbserver>
>> <alias>Fbot</alias>
>> <sname>fiscmmk410win</sname>
>> <port>80</port>
>> </app>
>> </webstats>
>>
>> as well if you want the app element(s) to be the record(s)/row(s) and the 
>> dir, dns and so on elements to be the columns.
>>
>>
>> -- 
>>
>> Martin Honnen --- MVP XML
>> http://JavaScript.FAQTs.com/
>
> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent