|
I'm trying to get a .txt file from another domain using xml object; this file includes special characters like ñ, á, é, í, ó, ú and so on.
The code I'm using is:
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")<br />
xml.Open "GET", "http://domain/file.txt", False<br />
xml.Send<br />
If err.number = 0 then filebody = xml.responseText<br />
set xml = nothing
The problem is that all those chars are converted to "?" symbols!
How can I get rid of this thing and get the original characters back?
Thanks a lot 4 your time!
Toby C
(sorry for cross-posting)
|
|
|
|
|
|
Hi.
I have the following element definition in my schema:
<xs:element name="Object">
<!-- must allow all element names and types -->
<xs:complexType mixed="true">
<xs:attribute name="reserved">
<xs:simpleType>
<xs:restriction base="xs:boolean"/>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
when i use an XML that validates with it and tries to define <TEST> element under it, i get an error on validation:
"<TEST> is not allowed under element <Object>"
i want to be able to add ANY element under this one. how can it do that in the schema?
Thanks.
|
|
|
|
|
|
This requires declaring this element in another schema...
but what i need is not declare it at all - just allow any element in the XML to be under the parent element.
|
|
|
|
|
Hi,
I have got some flat files which contain Smalltalk binary serialised objects.
I want the same to be converted in to XML so that I can load them in .Net.
Can anyone suggest an approach / solution for this problem.
Regards,
Tanmay
|
|
|
|
|
Here is snippet of my xml :
<Holidays>
<Months>
<Data>
<Name>August</Name>
</Data>
</Months>
<Days>
<Data>
<Day>1</Day>
<Holiday>Emancipation Day</Holiday>
<Country>(BRB, JAM, TTO)</Country>
</Data>
<Data>
<Day>1</Day>
<Holiday>Parents Day</Holiday>
<Country>(COG)</Country>
</Data>
............................................
Ok here is a Jscript function in my XSL code:
function showCountries(pass)
{
var results ='';
var sendtoDIVid = "requests";
switch(pass)
{
case pass:
results +='<p style="color: Navy">Countrys</p>'+
'<p style="color: Navy">'+pass+' 2006</p>'+
'<ul>'+
']]><xsl:for-each select="Holidays/Days/Data[Holiday = '+pass+']"><![CDATA['+
'<li style="color: navy">'+']]><xsl:value-of select="Country"/><[CDATA[</li>'+
']]></xsl:for-each><![CDATA['+
'</ul>'+
'</table>';
document.getElementById(sendtoDIVid).innerHTML = results;
break;
default:
}
}
]]>
</script>
...............................................
Ok the pass variable comes in and has a holiday for example 'Emancipation Day', that variable is then Checked agaisnt Holiday, then it will print out the country that celebrates 'Emancipation Day'.
Well it doesnt work, I know my logic is right becuase if type in 'Emancipation Day'where [Holiday = 'pass'] is at (so: [Holiday = 'Emancipation Day']) it works.
How do I get that Jscript variable to work?
PS. I already tried writing it so that pass had single quotes " ' " around it.
Please help.
|
|
|
|
|
Hi
Not sure if this a question for XML, SQL or .Net forum but here goes.
I have an XML file with a number of elements, one of which is,
<SQLQuery>select * from trainarrivals where ActiveFlag = 1 and DueTime between ('" + DateTime.Now.ToShortTimeString() + "') and ('" + (DateTime.Now.AddHours(1).ToShortTimeString()) + "')</SQLQuery>
I am using a C# application to read the file and connect to a MySql database. When I get this element the environment adds escape characters to the string so it looks like,
<SQLQuery>select * from trainarrivals where ActiveFlag = 1 and DueTime between ('\" + DateTime.Now.ToShortTimeString() + \"') and ('\" + (DateTime.Now.AddHours(1).ToShortTimeString()) + \"')</SQLQuery>
This in turn causes an exception in my code being thrown.
My question is, how can I write the xml file so the ( " ) is treated as such or change the string when it is read?
Thanks in advance and appologies if this is the wrong place!
|
|
|
|
|
richiemac wrote: DateTime.Now.ToShortTimeString()
What are you going to do with that as a string?
Maybe something like this will work better?
select * from trainarrivals where ActiveFlag = 1 and DueTime between ('?') and ('?')
led mike
|
|
|
|
|
Ok let me explain.
The string is an sql query that is stored in an xml config file. The DateTime stuff is so i can check the database for records within a certain time frame.
I am getting the string from the config file and trying to use concatenation to get the current time - the config will be called at different times and only wants values from the database for the next hour. If I hard code the string in the IDE, e.g.
string sqlStr = "...";
then all works fine. The problem arises when I get the stored string from config.
The reason I'm storing the string in config is because there are many different queries that depend on certain other aspects. The config thing needs to stay in place so I have to get it working this way (if possible).
Hope this clears up the confusion.
Rich
|
|
|
|
|
richiemac wrote: Hope this clears up the confusion.
No it does not. If DateTime.Now.ToShortTimeString() is a TSQL statement then why do you have a "string" in a config file instead of a Stored Procedure?
led mike
|
|
|
|
|
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.
|
|
|
|