Parse XML with asp

Filed Under (Software Development) by admin on 19-10-2011

I am using asp and sending data to my payment gateway for processing. When processed it returns xml back to me that I use. How do I get the values from this response? Response would be returned in this format:

<?xml version=”1.0″ encoding=”UTF-8″?>
<Result>
<TransTime>Mon Nov 08 20:21:06 PST 2004</TransTime>
<OrderID>2004110820210605147</OrderID>
<Approved>APPROVED</Approved>
<ReturnCode>Y:TEST:TESTTRANS:M:X:YYY</ReturnCode>
<ErrMsg></ErrMsg>
<TaxTotal>5.00</TaxTotal>
<ShipTotal>15.00</ShipTotal>
<SubTotal>55.00</SubTotal>
<FullTotal>75.00</FullTotal>
<PaymentType>CC</PaymentType>
<CardNumber>411111…1111</CardNumber>
<CardExpMonth>05</CardExpMonth>
<CardExpYear>07</CardExpYear>
<TransRefNumber>1bd0082c392b7c5b</TransRefNumber>
<CardIDResult>M</CardIDResult>
<AVSResult>X</AVSResult>
<CardAuthNumber>TEST</CardAuthNumber>
<CardRefNumber>TESTTRANS</CardRefNumber>
<CardType>VISA</CardType>
<IPResult>YYY</IPResult>
<IPCountry>CA</IPCountry>
<IPRegion>Ontario</IPRegion>
<IPCity>Toronto</IPCity>
</Result>

This is the code I am using to test with for now:

set xml = Server.CreateObject(“Microsoft.XMLHTTP”)
set xmlDoc = Server.CreateObject(“Microsoft.XMLDOM”)

xml.open “POST”, “##HOST ADDRESS##”, false
xml.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”
xml.send (orderString)
xmlResponseStr = xml.responseText
Response.Write(“<br /><br />”)
Response.write(xmlResponseStr)

‘ Parse Returned XML
set xmlDoc = Server.CreateObject(“Microsoft.XMLDOM”)
xmlDoc.async = True
xmlDoc.Load(xml.responseXML)

Set itemList = xmlDoc.getElementsByTagName(“*”)

Dim xmlApproved

Response.Write(“<br /><br />”)

For Each item In itemList
Response.Write(“IN HERE”)
For each child in item.childNodes
Response.Write(“IN DEEPER”)
Response.Write(child.nodeName)
Response.Write(“<br /><br />”)
Next
Next

Set xmlDoc = Nothing
Set itemList = Nothing
Set xml = nothing
%>

As you may see this is the first time I have ever attempted something like this.

How to layout 6 images in two rows if you want to use XHTML and CSS?

Filed Under (Software Development) by admin on 11-03-2009

I am a bit of a self taught newbie. I have a website that layouts out some images with a brief description under them as in a product catalogue. I would like to have six images 3 on each of two rows. I have done it with a table in HTML. But I would like to redo the page in strict XHTML and CSS.

Can anyone give me a quick guide as to how to do this or point me to a good tutorial on this (I have not been able to find one)? Im planning to sort it out something like that:

div.clearer {
clear: both;
height: 0px;
}

Ok, I’m not completely disputing the table idea but… this looks more like a list to me. A list of images (and descriptions), a list of products… a sequential list of items one after the other. Why is this tabular data? What is the relationship between rows and columns?
A list can be styled to have 3 columns and 2 (or however many) rows in a similar way to koan’s method… floating the LI’s and setting width:33%. Or you could fix the width of your LI’s (presumably your images are fixed width) and allow the list to flow – showing 3 columns at your optimum resolution/viewport size but perhaps more or less depending on the size of the users viewing device – depending how flexible your layout is. You can’t do this with a table. A list is also easier to markup and output dynamically from a serverside script.

iframe content depending on menu choice.

Filed Under (Software Development) by admin on 02-03-2009

Hey all,

I am struggling to develop my website based on what I can find on the web without any formal training.

I have succeeded in creating a two level menu where the 2nd level is displayed (expanded in accordeo fashion) when moving the cursor over the 1st level button thanks to a javascript found on the web which I customized. Read the rest of this entry »

How to capture HTTP Response headers of the same page using PHP

Filed Under (Software Development) by admin on 24-02-2009

Hi All, I have a requirement of displaying HTTP Response headers in the same page being redered using PHP.
This is to track various responses sent by the Apache Server for same page on different scenarios (like 200, 304, 503)
Read the rest of this entry »

Java inside Java

Filed Under (Software Development) by admin on 17-02-2009

I have a client that wants to run a .js file inside a .js file because of the registration form. *(

if (notes2 == “yes”) {
document.write(‘<fieldset><legend>’);

document.write(‘Notes Area<br></legend>’);

document.write(‘<center>Blurb Text Here that shows up on webpage<br><br><script type=”text/javascript” src=”http://forms.example.com/form/XX/4#*$!#*$!xx.js”></script><br>More blurb text that shows up after the reg. box</center>’);

document.write(‘</fieldset>’);
document.write(‘<br><br>’);
}
)*

This code places the box where it should be in Firebox but in IE 7 the registration box is at the bottom of the table, not between the two text blurbs. Any idea how I can get this to show up in IE? if it’s “just not rendering” try breaking up the code. Weird things sometimes happen with Javascript within document.write.

document.write(‘<scr’+'ipt type=”text/jav’+'ascr’+'ipt” src=”http://forms.example.com/form/XX/4#*$!#*$!xx.js”></scr’+ipt>’);

Second, your formatting is likely a result of a combination of Quirks mode and deprecated tags/discouraged approaches to formatting. Use a valid document type and validate your pages, this will make 90% of your formatting problems go away, Javascript or not.

To solve that, here is how I’d handle this (but move inline styles to external style sheets.) You may have to insert text-align:center and width:400px (or some valid value) to get the effects you want:

document.write(‘<fieldset style=”margin:auto;”>’);
document.write(<legend>’Notes Area<br></legend>’);
document.write(‘<p style=”text-align:center”>Blurb Text Here that shows up on webpage</p>’);

document.write(‘<div style=”margin:auto;”>’);
document.write(‘<scr’+'ipt type=”text/jav’+'ascr’+'ipt” src=”http://forms.example.com/form/XX/4#*$!#*$!xx.js”></scr’+ipt>’);
document.write(‘</div>’);

<!–
if you still have problems
add document.write(‘<div style=”clear:both;”></div>’);
right here
–>

document.write(‘<p style=”text-align:center”>More blurb text that shows up after the reg. box</p>’);
document.write(‘</fieldset>’);

Note the clearing div, you probably won’t need it, or can set the last p to clear, or overflow: none on the div containing the script – but overall, Standards Mode and semantic output should help you.