hi guys
im fairly new to xml so bear with me if this is a newbie question. I have an xml file -
<?xml version="1.0" encoding="utf-8" ?>
-
<promos>
-
<flight type="OW">
-
<url></url>
-
<departure>Gatwick</departure>
-
<destination>TORONTO</destination>
-
<departuredate year="2010" month="5" day="27, 28"/>
-
<price>139</price>
-
<currencycode>£</currencycode>
-
</flight>
-
<flight type="OW">
-
<url></url>
-
<departure>Gatwick</departure>
-
<destination>Vancouver</destination>
-
<departuredate year="2010" month="5" day="7, 8, 9"/>
-
<price>149</price>
-
<currencycode>£</currencycode>
-
</flight>
-
</promos>
-
and I'd like to retrieve the price from our sql database - but when I try to insert asp code in to this xml file it errors.. is it not possible to insert asp code within an xml file?
can you insert xml code in an asp file as an alternative? or is there a way to insert an asp file in to an xml file as an include??
please advise
thanks
18 1976
you can insert ASP code, but you have to do it in a processing instruction node or CDATA node ( ref.)
thanks for the quick reply - so in my case rather than
instead wrap it within cdata node? -
<price><![CDATA[ ASP CODE HERE ]]></price>
-
?
that depends on how you want to handle the code.
im not with you - can you please elaborate...
what is the purpose of the ASP code?
to connect to sql db and retrieve data - i.e in this case an integer to go inbetween the price xml tag..
regards
Omar.
so you want to execute the ASP before loading/reading/whatever the XML?
then write an ASP page, that returns the ready made XML file.
you’d need the processing instruction, if you’d execute the ASP afterwards.
example in PHP, since I don’t know ASP - <?php
-
// file: price.php
-
header("Content-Type: text/xml");
-
echo '<?xml version="1.0" ?>';
-
include "functions.inc";
-
$price = getPriceFromDB();
-
?>
-
<price><?php echo $price; ?></price>
I don't want to create another asp page as I'm trying to maintain as few pages as possible.
Ideally I just want to use an xml page and retrieve a value [in my case a price] using asp from a sql database.
can anyone else advise of any solutions please?
thanks in advance
I don't want to create another asp page as I'm trying to maintain as few pages as possible.
and how do you tell the ASP interpreter to execute the code?
Ideally I just want to use an xml page and retrieve a value [in my case a price] using asp from a sql database.
XML doesn’t do that.
okay - alternatively if I created another asp file to retrieve a value from sql db and then pull in this asp file within the xml as an include? so something like this -
<price><![CDATA[<!--#include virtual="price.asp" -->]]></price>
-
would that work?
a) you don’t need CDATA tags
b) if you tell the ASP interpreter to parse the XML file
… maybe, you have to ask someone knowledgeable in ASP for the exact procedure.
correct me if im wrong but are you trying to say to use an asp file instead of an xml file and then output/convert the asp to xml?
I have to use an xml file as we are sending this xml file to a 3rd party company so they are expecting an xml file.
I will ask in the asp section for some advise - if you have any other ideas please do let me know.
be well
Omar.
I have to use an xml file as we are sending this xml file to a 3rd party company so they are expecting an xml file.
that depends on how you deliver. if they just access the file over the net (i.e. only reading) that doesn’t matter, because you give them an XML file (MIME type overrides file extension).
if you send the file (e.g. via email), you have to dump the result into a file (which may bear any name or file extension you like)
we do not send them the file via email thats for sure - they appear to read it as they have ftp access to our files etc but I will find out for 100% sure on details.
im not sure what you mean by 'dump the result into a file'...
im not sure what you mean by 'dump the result into a file'...
I mean: "save as …"
so it appears that you have to save the result XML code to a file, since the 3rd party does not/cannot make use of the ASP interpreter. (you have to write a script, that generates the XML file)
OK, so you need to generate an XML file from database data, which is then accessed via FTP via a third-party.
You'd generate the XML file as a string in ASP, then save it as an XML file to disk.
In pseudo-code: -
<%
-
'Connect to DB
-
String myXml = "<price>{0}</price>"
-
'dr is your recordset with the data pulled from your DB
-
String myXml = Replace(myXml, "{0}", dr("Price"))
-
Dim fso = CreateObject("Scripting.FileSystemObject")
-
Set fs = fso.CreateTextFile("myXmlFile.xml")
-
fs.WriteLine(myXml)
-
fs.Close
-
Set fs = Nothing
-
%>
-
Hope this helps.
codegecko
@omar999
Excuse me, but this is not a great idea. Why don't you try to work with XML from ASP and not inverse? I mean usually you'd have some data you need to insert into XML but this isn't too complex. I mean putting an ASP into XML just to take one value from database... is too strange and isn't really professional. I mean look at alternatives really. Perhaps the most correct thing to have a method that will do that for you and you just insert this value into xml.
codegecko - thanks for your reply. I've read your post several times and although I may not fully understand but I think this may be the way forward to generate the xml and then save the file on our server.
Monomachus - im trying to eradicate the need to manually enter in any data in to the xml file while it can just retrieve this data directly from our db. hence i want to automate this process. i need to retrieve aprox 4 values from sql db in to this xml file - and there's about 8 xml files so in the long run it will be worthwhile.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kingdom |
last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the
results. Choose a component type from the first drop down, lets say
'car' and the second box will list all the car...
|
by: Sunshine |
last post by:
My original thought was to save the recordset into a text file. However,
because of permissions I am unable to do this and will not be able to change
the permissions. My next thought was to open...
|
by: Steven T. Hatton |
last post by:
This is a purely *hypothetical* question. That means, it's /pretend/,
CP. ;-)
If you were forced at gunpoint to put all your code in classes, rather than
in namespace scope (obviously classes...
|
by: Shawn Milo |
last post by:
I put this together yesterday, and I thought I'd share it.
It works in both IE and Mozilla Firefox. I posted something
similar to this months back, but it was much longer, and only
worked in IE....
|
by: pamelafluente |
last post by:
I am trying to pass a javascript variable to ASP.
It almost works, except for the postback part. Infact if one clicks on
the div and on the button it can be seen that the variable passes...
|
by: jpr |
last post by:
Hello,
I have a form on which I have a cmdbutton to copy a couple of fields
into another table (MASTER) using the SSN on the active form as
criteria.
In the active form (based on a tables...
|
by: Kosmos |
last post by:
Hey guys...as a relatively new programmer, I try to give back where I can. Below is the code for a useful program I believe many of you could use...just don't use the same exact code because...well I...
|
by: Eric Layman |
last post by:
Hi,
Many years ago when I first learnt abt web dev in school,
I was taught this methodology:
<html>
blah blabh
|
by: rn5a |
last post by:
I want an ASP app to retrieve records from a MS-Access database table
but display them in a HTML table but I want the HTML table table to
display only 7 records in a row (<tr>...</tr>) in 7...
|
by: Subrato |
last post by:
Hi,
I am very new to xml and I have this piece of code which I took off
a website. The situation is that on of the website, user files up a
form and it is submitted. On submission, the page should...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |