|
Config files are used because the app has to have the ability to read any appropriate config and use the query string. Users can therefore add new config files that will be read.
At this time the query could be anything so I therefore wouldn't use stored procs. Plus using stored procs now would mean major changes that time doesn't allow for.
The DateTime.Now.ToShortTimeString() is a .net System statement that I'm trying to concatenate into the query string that is read from the config.
If I can't do it in this way is there anyway aroud this without having to make big changes?
|
|
|
|
|
richiemac wrote: that I'm trying to concatenate into the query string that is read from the config.
Ok we are still having some confusion because in your first post ...
richiemac wrote: I have an XML file with a number of elements, one of which is,
and you follow that with the SQL statement including the DateTime.Now.ToShortString() etc.... so.... now it seems that the DateTime.Now.ToShortString() is NOT in the XML data, is that true? If so then my first post offers an example of how you could deal with the problem. If this:
select * from trainarrivals where ActiveFlag = 1 and DueTime between ('@DTStart') and ('@DTEnd')
was in the XML then you could use a System.Data.SqlClient.SqlCommand giving it the string and then setting the parameters using DateTime.Now.XXXX() methods.
see the documentation[^] for details.
does that help?
led mike
|
|
|
|
|
Cheers my friend!
Got it working - eventually. Again thanks for the help.
Rich
|
|
|
|
|
I'm new to xsl. Here is a snippet of my xml:
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<Picture PhotoID="2259" Owner="Brent" Title="Test Picture" Url="http://www.mysite.com/1.jpg" " />
</DocumentElement>
And here is my xsl:
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Pictures</title>
<link>http://www.mysite.com/</link>
<description>Pictures</description>
<managingEditor>brent@mysite.com</managingEditor>
<language>en-us</language>
<xsl:for-each select='DocumentElement/Picture'>
<item>
<guid isPermaLink="false">
<xsl:value-of select='PhotoID'/>
</guid>
<title>
<xsl:value-of select='Title'/>
</title>
</item>
</xsl:for-each>
</channel>
</rss>
</xsl:template>
</xsl:stylesheet>
Note: they might not match up exactly since I changed it to hide secure data.
Anyway, my question is, how do I get to the values in each of my Picture elements? Doing this:
<xsl:value-of select='PhotoID'/>
does not work. I think it would if my xml looked like:
<pre>
<Picture>
<PhotoID>1234</PhotoID>
</Picture>
</pre>
How do I change my xsl to get the PhotoID, given the xml format above?
"Half this game is ninety percent mental." - Yogi Berra
If you can read thank a teacher, if you can read in English, thank a Marine.
M y and h don't work so well due to m addiction to caffeine and m in abilit to to set a cup down uprigt.
|
|
|
|
|
Ok, I figured it out. I just needed the @ symbol in front. Once I learned that I needed to get the value of the "attribute" a google search made it easy to find. I guess what held me back here was the terminolgy.
|
|
|
|
|
try writing following:
<xsl:value-of select='@PhotoID'></xsl:value-of>
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Thank you, yes that is what I needed.
|
|
|
|
|
Hi, I have problem with loading xml file wich content is:
<code>
<?xml version="1.0" encoding="utf-8" ?>
<identity impersonate="true"></identity>
<forum>
<guest>
<name>Sonu Kapoor</name>
<email>sonu@codefinger.de</email>
<comment>cvvvc</comment>
</guest>
</forum>
</code>
Everytime I try to load this file through xmldoc.Load it throws an exception:
<code>
[XmlException: There are multiple root elements. Line 4, position 2.]
</code>
I think that problem is in <identity impersonate="true"></identity>, but I need this to be included because in other case I can't read/write to this document. Thx for replies.
-- modified at 15:21 Monday 28th August, 2006
//==============================
"Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."
Dick Brandon
|
|
|
|
|
Tomi87 wrote: There are multiple root elements
Do you not know that valid XML must have a single root element?
led mike
|
|
|
|
|
Yes I know that. My root element is forum, but I don't know how to add identity tag to file and solve the problem.
//==============================
"Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."
Dick Brandon
|
|
|
|
|
<?xml version="1.0" encoding="utf-8" ?>
<forum>
<identity impersonate="true"></identity>
<guest>
<name>Sonu Kapoor</name>
<email>sonu@codefinger.de</email>
<comment>cvvvc</comment>
</guest>
</forum>
led mike
|
|
|
|
|
Hi,
I have been given an .xml file to investigate how it produces data.
Basically there is a file called testData.xml
when this file is double clicked, it opens up in excel with data.
If you right click and open in excel then a properly formatted excel workbook with two named sheets appear which have both got formatted data in them.
I have pasted the first few lines of the xml file for you to see.
Could you let me know how this is possible and where is the data coming from?
<?xml version="1.0" ?>
- <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns ="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
- <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Ursula Bitterlin</Author>
<LastAuthor>874496</LastAuthor>
<LastPrinted>2006-07-05T15:45:06Z</LastPrinted>
<Created>2005-01-12T14:14:33Z</Created>
<LastSaved>2006-07-10T11:15:56Z</LastSaved>
<Company>Engineering</Company>
<Version>10.6735</Version>
</DocumentProperties>
- <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<DownloadComponents />
<LocationOfComponents HRef="/" />
</OfficeDocumentSettings>
- <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>5325</WindowHeight>
<WindowWidth>11820</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>60</WindowTopY>
<ActiveSheet>1</ActiveSheet>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
- <Styles>
- <Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom" />
<Borders />
<Font />
<Interior />
<NumberFormat />
<Protection />
</Style>
- <Style ss:ID="s16" ss:Name="Comma">
<NumberFormat ss:Format="_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_" />
</Style>
|
|
|
|
|
I have the following XML and struggling to sort it how I need it..
<MyStuff>
<Job name="Job1" oldvalue="" type="Report 1" seq="29" >
< Param name="name" value="EARTH" newvalue="" />
< Param name="Colour" value="YELLOW" newvalue="" />
</Job>
<Job name="Job2" oldvalue="" type="Report 1" seq="29" >
< Param name="name" value="WIND" newvalue="" />
< Param name="Colour" value="GREEN" newvalue="" />
</Job>
<Job name="Job3" oldvalue="" type="Report 1" seq="29" >
< Param name="name" value="FIRE" newvalue="" />
< Param name="Colour" value="RED" newvalue="" />
</Job>
<Job name="Job4" oldvalue="" type="Report 1" seq="29" >
< Param name="name" value="DISCO" newvalue="" />
< Param name="Colour" value="BLUE" newvalue="" />
</Job>
</MyStuff>
I want to display the <Job> element, but have them sorted by a child element. eg display the Jobs in alphabetical order of Colour. I use the following snippet to sort on the higher level branch, (@seq) but i now want it sorted on /Param/[@name="Colour"] , or some syntax like that
System.Xml.XPath.XPathExpression exprBatch1 = xmlNavBatch1.Compile(String.Format("/MyStuff/Job", batch));
exprBatch1.AddSort("@seq", System.Xml.XPath.XmlSortOrder.Ascending, System.Xml.XPath.XmlCaseOrder.None, "", System.Xml.XPath.XmlDataType.Number);
Anybody any idea?
Regards
Malc
*********************************************
|
|
|
|
|
My XSL takes a date in this format: 2007-06-04T00:00:00 (Year/Month/Day/Time) from an SQL query that outputs FOR XML.
I would like the XSL to output it like so: dd/MM/yyyy (British date style)
How would i go about doing this in XSL?
or is it simpler to control the output style in SQL ?
Thanks.
|
|
|
|
|
You could possibly do it in XSL if there was support for XPath 2.0, but that's not likely. The SQL way is probably going to be the easiest. Also, if your stylesheet is only run though msxml, you can use a script. Here's an example:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:date-time="http://mycompany.com/mynamespace"
version="1.0"
exclude-result-prefixes="date-time msxsl">
...
<xsl:value-of select="date-time:GetMyDate()"/>
...
<msxsl:script language="JavaScript" implements-prefix="date-time">
<![CDATA[
function GetMyDate()
{
var myDate = new Date()
var y = myDate.getFullYear()
var m = EnsureLength(myDate.getMonth() + 1, 2)
var d = EnsureLength(myDate.getDate(), 2)
var h = EnsureLength(myDate.getHours(), 2)
var min = EnsureLength(myDate.getMinutes(), 2)
var s = EnsureLength(myDate.getSeconds(), 2)
var mil = EnsureLength(myDate.getMilliseconds(), 3)
return y + "-" + m + "-" + d + "-" + h + min + s + mil
}
function EnsureLength(s,n)
{
s = new String(s)
while (s.length < n)
s = "0" + s;
return s;
}
]]>
</msxsl:script>
</xsl:stylesheet>
The EnsureLength function I created because I couldn't find a string padding function in JavaScript.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Hello:
I am now creating an excel file using xslt with the code below:
dim objFsXML as System.IO.StringReader
dim objXmlTxtWrt as System.Xml.XmlTextReader
dim objXPath as System.Xml.Xpath.XpathDocument
dim objXslTran as System.Xml.Xsl.XslTransform
'Create Output Stream to write the file to disk
objFsXML = New System.IO.FileStream(strExcelFile,System.IO.FileMode.Create)
objXmlTxtWrt = New XmlTextWriter(objFsXML,System.Text.Encoding.Unicode)
'Create Xpath Doc to be given as used while doing the XSL Trannsfor
objStrRdr = New StringReader(dsDataSet.GetXml)
objXmlTxtRdr = New XmlTextReader(objStrRdr)
objXPath = New XPath.XPathDocument(objXmlTxtRdr)
objXslTran = New Xsl.XslTransform
objXslTran.Load(strXSLTempFile)' here throws exception
However, when there is a blank or a special char in one of my headers, i've got an invalid xpath expression which throw an exception
what can i do ?
thx
-- modified at 22:55 Wednesday 23rd August, 2006
|
|
|
|
|
hi
can any one tell me how to remove perticular node from xml file through c#
plz help
Rahul Khokale
|
|
|
|
|
I believe the XmlDocument class has a Remove method.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I want the client to be able to save the svg doc he/she modified on my web app
but I don't know how to write javascript that provide that functionality.
I have found several example on saving format such as txt and html.
But could not find one for svg. I want it to be saved as .svg because the client can see it as picture still unlike saving as txt.
|
|
|
|
|
How insert data in old xml file.
I want old data in xml as it is when i insert new next time in same xml
|
|
|
|
|
You could load data from xml file into XmlDocument, then add new xml data and save to the same file again.
Something like this:
XmlDocument doc = new XmlDocument();
doc.Load("file_path.xml");
XmlElement element = doc.CreateElement("NewElement");
element.InnerText = "test data";
doc.DocumentElement.AppendChild(element);
doc.Save("file_path.xml");
Vitaliy Tsvayer
Tikle
|
|
|
|
|
I've seen this question enough times that I wrote an article on it: Link[^]
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
|
...which is why I'm pasting in 300 lines of code
The ParseDaysXML routine is based on the ParseWeatherXML Routine. Not surprisingly, the code I copeid and pasted is working fine, but the stuff I tried to adapt isn't.
The commented code in ParseDaysXML is what is causing the problem. Based on the "Object reference not set to an instance of an object" error pointing to line 123 (second Dim line in the FindLayoutTable function), I'm suspecting something isn't right with my SelectSingleNode line (the first commented one).
So, three questions:
1) What is causing the error
2) how to fix?
3) My goal is simply to get period name from the WKKI2.xml file matched with the appopriate period in thew WKKI.xml file. Is there a more efficient way to go about it?
Thanks in advance....
Scott
---------------------------
Imports System.Xml
Imports System.Text
Imports System.Math
Public Class NWS_XML
#Region "Structs"
Private strStation As String
Private Structure WeatherTable
Public nodTimeLayout As XmlNode
Public nodData As XmlNode
End Structure
Private Structure WeatherData
Public wtHighTemp As WeatherTable
Public wtLowTemp As WeatherTable
Public wtLiquidPrecip As WeatherTable
Public wtSnowPrecip As WeatherTable
Public wtPrecipProb As WeatherTable
Public wtWindSpeed As WeatherTable
Public wtWindDirection As WeatherTable
Public wtCloudCover As WeatherTable
Public wtDayName As WeatherTable
Public wtNightName As WeatherTable
End Structure
Private Structure DayData
Public PeriodName As String
Public dt As Date
End Structure
Private Structure TemperatureData
Public F As Integer
Public ReadOnly Property C() As Integer
Get
Return Integer.Parse(Math.Round(((Double.Parse(F) - 32) / 9) * 5))
End Get
End Property
Public dt As Date
End Structure
Private Structure PrecipitationData
Public Inches As Double
Public ReadOnly Property MM() As Double
Get
Return Inches * 25.4
End Get
End Property
Public dt As Date
End Structure
Private Structure PercentData
Public Pct As Integer
Public dt As Date
End Structure
Private Structure WindData
Public Knots As Integer
Public ReadOnly Property MPH() As Integer
Get
Return Integer.Parse(Math.Round((Double.Parse(Knots) * 6076.12) / 5280))
End Get
End Property
Public Degrees As Integer
Public ReadOnly Property Dir() As String
Get
Select Case Degrees
Case 0 To 11.25, 348.75 To 360
Return "N"
Case 11.25 To 33.75
Return "NNE"
Case 33.75 To 56.25
Return "NE"
Case 56.25 To 78.75
Return "ENE"
Case 78.75 To 101.25
Return "E"
Case 101.25 To 123.75
Return "ESE"
Case 123.75 To 146.25
Return "SE"
Case 146.25 To 168.75
Return "SSE"
Case 168.75 To 191.25
Return "S"
Case 191.25 To 213.75
Return "SSW"
Case 213.75 To 236.25
Return "SW"
Case 236.25 To 258.75
Return "WSW"
Case 258.75 To 281.25
Return "W"
Case 281.25 To 303.75
Return "WNW"
Case 303.75 To 326.25
Return "NW"
Case 326.25 To 348.75
Return "NNW"
End Select
End Get
End Property
Public dt As Date
End Structure
Private Structure FormattedWeatherData
Public HighTemp() As TemperatureData
Public LowTemp() As TemperatureData
Public LiquidPrecip() As PrecipitationData
Public SnowPrecip() As PrecipitationData
Public PrecipProb() As PercentData
Public Wind() As WindData
Public CloudCover() As PercentData
Public DayName() As DayData
Public NightName() As DayData
End Structure
#End Region
#Region "NWS XML Reader http://www.nws.noaa.gov/forecasts/xml"
Private Function FindLayoutTable(ByVal xmlDoc As XmlDocument, ByVal nodData As XmlNode)
Dim nlTimeLayouts As XmlNodeList = xmlDoc.SelectNodes("/dwml/data/time-layout")
Dim strTimeLayout As String = nodData.Attributes("time-layout").Value
Dim node As XmlNode
For Each node In nlTimeLayouts
If strTimeLayout = node.SelectSingleNode("layout-key").InnerText Then
Return node
End If
Next
Return Nothing
End Function
Private Function ParseDateTime(ByVal str As String) As Date
Return Date.Parse(str.Replace("T", " ").Substring(0, str.LastIndexOf("-")))
End Function
Private Sub FillTemperatureData(ByVal wt As WeatherTable, ByRef temp() As TemperatureData)
Dim intCount As Integer
Dim nlData As XmlNodeList = wt.nodData.SelectNodes("value")
Dim nlDate As XmlNodeList = wt.nodTimeLayout.SelectNodes("start-valid-time")
For intCount = 0 To UBound(temp) - 1
temp(intCount) = New TemperatureData()
temp(intCount).F = Integer.Parse(nlData(intCount).InnerText)
temp(intCount).dt = ParseDateTime(nlDate(intCount).InnerText)
Next
End Sub
Private Sub FillPrecipitationData(ByVal wt As WeatherTable, ByRef precip() As PrecipitationData)
Dim intCount As Integer
Dim nlData As XmlNodeList = wt.nodData.SelectNodes("value")
Dim nlDate As XmlNodeList = wt.nodTimeLayout.SelectNodes("start-valid-time")
For intCount = 0 To UBound(precip) - 1
precip(intCount) = New PrecipitationData()
If Len(nlData(intCount).InnerText) = 0 Then
precip(intCount).Inches = 0
Else
precip(intCount).Inches = Double.Parse(nlData(intCount).InnerText)
End If
precip(intCount).dt = ParseDateTime(nlDate(intCount).InnerText)
Next
End Sub
Private Sub FillPercentData(ByVal wt As WeatherTable, ByRef pct() As PercentData)
Dim intCount As Integer
Dim nlData As XmlNodeList = wt.nodData.SelectNodes("value")
Dim nlDate As XmlNodeList = wt.nodTimeLayout.SelectNodes("start-valid-time")
For intCount = 0 To UBound(pct) - 1
pct(intCount) = New PercentData()
pct(intCount).Pct = Integer.Parse(nlData(intCount).InnerText)
pct(intCount).dt = ParseDateTime(nlDate(intCount).InnerText)
Next
End Sub
Private Sub FillWindData(ByVal wtSpeed As WeatherTable, ByVal wtDir As WeatherTable, ByRef wind() As WindData)
Dim intCount As Integer
Dim nlSpeed As XmlNodeList = wtSpeed.nodData.SelectNodes("value")
Dim nlDir As XmlNodeList = wtDir.nodData.SelectNodes("value")
Dim nlDate As XmlNodeList = wtSpeed.nodTimeLayout.SelectNodes("start-valid-time")
For intCount = 0 To UBound(wind) - 1
wind(intCount) = New WindData()
wind(intCount).Knots = Integer.Parse(nlSpeed(intCount).InnerText)
wind(intCount).Degrees = Integer.Parse(nlDir(intCount).InnerText)
wind(intCount).dt = ParseDateTime(nlDate(intCount).InnerText)
Next
End Sub
Private Sub FillDayData(ByVal wt As WeatherTable, ByRef DName() As DayData)
Dim intCount As Integer
Dim nlData As XmlNodeList = wt.nodData.SelectNodes("value")
Dim nlDate As XmlNodeList = wt.nodTimeLayout.SelectNodes("period-name")
For intCount = 0 To UBound(DName) - 1
DName(intCount) = New DayData()
DName(intCount).PeriodName = nlData(intCount).InnerText
DName(intCount).dt = ParseDateTime(nlDate(intCount).InnerText)
Next
End Sub
Private Function ParseForecastXML(ByVal strXMLWeather) As FormattedWeatherData
Try
'Setup variables
Dim xmlDoc As New XmlDocument()
Dim wdData As New WeatherData()
Dim fwdData As New FormattedWeatherData()
wdData.wtHighTemp = New WeatherTable()
wdData.wtLowTemp = New WeatherTable()
wdData.wtLiquidPrecip = New WeatherTable()
wdData.wtSnowPrecip = New WeatherTable()
wdData.wtPrecipProb = New WeatherTable()
wdData.wtWindSpeed = New WeatherTable()
wdData.wtWindDirection = New WeatherTable()
wdData.wtCloudCover = New WeatherTable()
'Load XML data
xmlDoc.Load(strXMLWeather)
'Load data and their corresponding time nodes
wdData.wtHighTemp.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/temperature[@type='maximum']")
wdData.wtLowTemp.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/temperature[@type='minimum']")
wdData.wtLiquidPrecip.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/precipitation[@type='liquid']")
wdData.wtSnowPrecip.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/precipitation[@type='snow']")
wdData.wtPrecipProb.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/probability-of-precipitation[@type='12 hour']")
wdData.wtWindSpeed.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/wind-speed[@type='sustained']")
wdData.wtWindDirection.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/direction[@type='wind']")
wdData.wtCloudCover.nodData = xmlDoc.SelectSingleNode("/dwml/data/parameters/cloud-amount[@type='total']")
wdData.wtHighTemp.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtHighTemp.nodData)
wdData.wtLowTemp.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtLowTemp.nodData)
wdData.wtLiquidPrecip.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtLiquidPrecip.nodData)
wdData.wtSnowPrecip.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtSnowPrecip.nodData)
wdData.wtPrecipProb.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtPrecipProb.nodData)
wdData.wtWindSpeed.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtWindSpeed.nodData)
wdData.wtWindDirection.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtWindDirection.nodData)
wdData.wtCloudCover.nodTimeLayout = FindLayoutTable(xmlDoc, wdData.wtCloudCover.nodData)
'Setup formatted data variables
ReDim fwdData.HighTemp(wdData.wtHighTemp.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdData.LowTemp(wdData.wtLowTemp.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdData.LiquidPrecip(wdData.wtLiquidPrecip.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdData.SnowPrecip(wdData.wtSnowPrecip.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdData.PrecipProb(wdData.wtPrecipProb.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdData.Wind(wdData.wtWindSpeed.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdData.CloudCover(wdData.wtCloudCover.nodTimeLayout.SelectNodes("start-valid-time").Count)
'Fill in data
FillTemperatureData(wdData.wtHighTemp, fwdData.HighTemp)
FillTemperatureData(wdData.wtLowTemp, fwdData.LowTemp)
FillPrecipitationData(wdData.wtLiquidPrecip, fwdData.LiquidPrecip)
FillPrecipitationData(wdData.wtSnowPrecip, fwdData.SnowPrecip)
FillPercentData(wdData.wtPrecipProb, fwdData.PrecipProb)
FillWindData(wdData.wtWindSpeed, wdData.wtWindDirection, fwdData.Wind)
FillPercentData(wdData.wtCloudCover, fwdData.CloudCover)
Return fwdData
Catch ex As Exception
MsgBox(ex.ToString)
Return Nothing
End Try
End Function
Private Function ParseDaysXML(ByVal strXMLWeather) As FormattedWeatherData
Try
'Setup variables
Dim xmlDaysDoc As New XmlDocument()
Dim wdDaysData As New WeatherData()
Dim fwdDaysData As New FormattedWeatherData()
'Load XML data
xmlDaysDoc.Load(strXMLWeather)
'Load data and their corresponding time nodes
'wdDaysData.wtDayName.nodData = xmlDaysDoc.SelectSingleNode("/dwml/data/time-layout/start-valid-time/@period-name")
'wdDaysData.wtNightName.nodData = xmlDaysDoc.SelectSingleNode("/dwml/data/time-layout/start-valid-time/@period-name")
wdDaysData.wtHighTemp.nodData = xmlDaysDoc.SelectSingleNode("/dwml/data/parameters/temperature[@type='maximum']")
wdDaysData.wtLowTemp.nodData = xmlDaysDoc.SelectSingleNode("/dwml/data/parameters/temperature[@type='minimum']")
'wdDaysData.wtDayName.nodTimeLayout = FindLayoutTable(xmlDaysDoc, wdDaysData.wtDayName.nodData)
'wdDaysData.wtNightName.nodTimeLayout = FindLayoutTable(xmlDaysDoc, wdDaysData.wtNightName.nodData)
wdDaysData.wtHighTemp.nodTimeLayout = FindLayoutTable(xmlDaysDoc, wdDaysData.wtHighTemp.nodData)
wdDaysData.wtLowTemp.nodTimeLayout = FindLayoutTable(xmlDaysDoc, wdDaysData.wtLowTemp.nodData)
'Setup formatted data variables
'ReDim fwdDaysData.DayName(wdDaysData.wtDayName.nodTimeLayout.SelectNodes("start-valid-time").Count)
'ReDim fwdDaysData.NightName(wdDaysData.wtNightName.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdDaysData.HighTemp(wdDaysData.wtHighTemp.nodTimeLayout.SelectNodes("start-valid-time").Count)
ReDim fwdDaysData.LowTemp(wdDaysData.wtLowTemp.nodTimeLayout.SelectNodes("start-valid-time").Count)
'Fill in data
'FillDayData(wdDaysData.wtHighTemp, fwdDaysData.DayName)
'FillDayData(wdDaysData.wtLowTemp, fwdDaysData.NightName)
FillTemperatureData(wdDaysData.wtHighTemp, fwdDaysData.HighTemp)
FillTemperatureData(wdDaysData.wtLowTemp, fwdDaysData.LowTemp)
Return fwdDaysData
Catch ex As Exception
MsgBox(ex.ToString)
Return Nothing
End Try
End Function
#End Region
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnWKKI.Click, btnKMAV.Click, btnWWWC.Click, btnKCHQ.Click
strStation = sender.Text
'load the weather array
Dim strWeatherXML As String = "http://distribution.customradionews.net/Forecast_XML/" & strStation & ".xml"
Dim fwdWeather As FormattedWeatherData = ParseForecastXML(strWeatherXML)
'load the days array
Dim strWeatherDaysXML As String = "http://distribution.customradionews.net/Forecast_XML/" & strStation & "2.xml"
Dim fwdWeatherDays As FormattedWeatherData = ParseDaysXML(strWeatherDaysXML)
|
|
|
|
|
Hi - Need help - some special characters are added to our XML document - unable to see this with notepad, wordpad, any type of XML readers like XMLSpy - is there a utility out there we could use? it adds this special characters at top of document ____ - the srainght line is the special characters.
thanks.
-- modified at 14:53 Friday 18th August, 2006
- Used Windiff - which displayed special characters.
- Removed the UTF-8 encoding - it seems to be causing error - leaving
- which seems to work for us.
|
|
|
|
|