ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old August 18th, 2003, 03:41 PM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
ASP using XML

ok i think i have it figured out how to produce an xml file. now how do i encorporate that into an asp file? such as using it to populate an option box. or just plain outputing it to the screen. i've looked at a couple of ways to do it with vbscript and javascript but none of them seemed to work to create option boxes in a form that will actually work. anyone have any sample code or know a site that shows how to do it?
__________________
My brain cells are like a storm trooper's armor: useless

Reply With Quote
  #2  
Old August 18th, 2003, 03:58 PM
mad8vskillz mad8vskillz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Philladelphia
Posts: 23 mad8vskillz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here's a chunk of code that parses a xml DOM...
i raped it a bit and since it's a piece it will not do anything in it's state, but its a decent base to go from...
see 3rd post

Last edited by mad8vskillz : August 18th, 2003 at 04:13 PM.

Reply With Quote
  #3  
Old August 18th, 2003, 04:04 PM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
uh, thanks i think.
anyone else have anything? or maybe an explaination of the code listed?

Reply With Quote
  #4  
Old August 18th, 2003, 04:10 PM
mad8vskillz mad8vskillz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Philladelphia
Posts: 23 mad8vskillz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ok, i'll try trimming it to what you will need
Code:

Set objSource = Server.CreateObject("Microsoft.XMLDOM") 'create the sqlreaderthingy

 
	'get XML string (so that you can do something with it)
	strXML=somefunction()
	
  'just some stuff you need 
	objSource.async = false
	objSource.loadXML strXML  
 
	'retrieve data for table OR report eof
	If ((objSource.readyState = 4) AND (objSource.parseError.errorCode = 0)) Then
		Set rootElement = objsource.documentElement  'for shorter xmldom calling
	
		if rootelement.getElementsByTagName("z:row").length-1=0 then  'check if rst is empty
%>		
Your Search did not find any matching records. Please press back button to try again
<%
		else 'records found, build table
			
   for i=0 to rootelement.getElementsByTagName("z:row").length-1        'go through the xml
		
    firstname=rootelement.getElementsByTagName("z:row").item(i).getattribute("firstname")  'get firstname (can be any other field) from xml

    response.write(firstname) 'do something with name
     
    next
   end if



sorry about formating, my pc is weird

Reply With Quote
  #5  
Old August 18th, 2003, 04:22 PM
aspman aspman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Ashburn,VA
Posts: 105 aspman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 22 m 40 sec
Reputation Power: 5
Hi Don,

here is a more simpler way of acheiving it.

The combo box that i am filling is just an INFO purpose and the length of the combo box is 5 which means users can see 5 values at a time.
We can certainly add "select one" at the top of a huge list of values.

function populatetgexstCombo(par)

{
var tgs;

//Data ISLAND to be declared in the body of the html and set it to asynchronous data read mode.
XMLtgexstID.async = false;

// Change Ddata Island source
XMLtgexstID.SRC="/<%=approot%>/data/tgexistslist.asp?coloid="+ par;

// Get recordset from XML data
var tgs = XMLtgexstID.getElementsByTagName("z:row");

// Fill combo with what is needed
for (var i=0; i < tgs.length; i++) {
if (tgs.item(i).attributes(1).text !="") {
form.combo.options[i]=new Option(tgs.item(i).attributes(1).text ,tgs.item(i).attributes(0).text);
}//end if
}//end for

// Delete extra entries
while (tgs.length < form.combo.options.length) {
form.combo.options[(step3.tgExst.options.length-1)] = null;
} //end while



}//END FUNCTION


and after the body tag in the html/asp page

add this

< XML ID="XMLtgexstID" > </XML>

---------------------------------------------------------------

Hope that helps. Let me know if you have any questions regarding the script

Reply With Quote
  #6  
Old August 18th, 2003, 09:28 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,560 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 16 h 32 m 3 sec
Reputation Power: 640
If you created your xml file by saving an ado recordset as an xml file, you can simply create an ado recordset on another page and rs.open "myxmlfile.xml" from the previously stored ado xml. Then use the recordset as if you just got it from a database.

Reply With Quote
  #7  
Old August 18th, 2003, 10:13 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag

Reply With Quote
  #8  
Old August 19th, 2003, 10:07 AM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
the more i look at xml the more i get confused. writing the schemas is easy enough, but how the heck do you get anything out of it. sure you can output it, but is there anyway to use asp to get the information you need? here is what i really want. take this schema:
Code:
<?xml version="1.0" ?> 
- <Hardware>
- <Listing>
  <HardwareID>1</HardwareID> 
  <Manufacturer>Compaq</Manufacturer> 
  <Product>EVO</Product> 
  </Listing>
- <Listing>
  <HardwareID>2</HardwareID> 
  <Manufacturer>IBM</Manufacturer> 
  <Product>T30</Product> 
  </Listing>
- <Listing>
  <HardwareID>3</HardwareID> 
  <Manufacturer>Sony</Manufacturer> 
  <Product>Vaio</Product> 
  </Listing>
  </Hardware>

and put it into this
Code:
<form name="form1">
     <select name="select1">
          <option value="<!--hardwareID-->"><!-- this is where the manufacturer and the product go, concatinated--></option>
     </select>
     <input type="submit" name="submit" value="submit">
</form>

no help from the xml forum so far. should this be easier, or at least possible to do if xml is going to be the next best thing? yeah i'm frustrated.

Reply With Quote
  #9  
Old August 19th, 2003, 10:28 AM
mad8vskillz mad8vskillz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Philladelphia
Posts: 23 mad8vskillz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
try messing with this (i did this in notepad, so it might be a little wrong)

Code:
<%@ Language=VBScript %>
<%
 
	Set objSource = Server.CreateObject("Microsoft.XMLDOM") 'create the sqlreaderthingy

 
	'get XML string (so that you can do something with it)
	strXML="<?xml version=1.0 ?>" 
	strXML=strXML+"- <Hardware>"
	strXML=strXML+"- <Listing>"
	strXML=strXML+"  <HardwareID>1</HardwareID> "
	strXML=strXML+"  <Manufacturer>Compaq</Manufacturer> "
	strXML=strXML+"  <Product>EVO</Product> "
	strXML=strXML+"  </Listing>"
	strXML=strXML+"- <Listing>"
	strXML=strXML+"  <HardwareID>2</HardwareID> "
	strXML=strXML+"  <Manufacturer>IBM</Manufacturer> "
	strXML=strXML+"  <Product>T30</Product> "
	strXML=strXML+"  </Listing>"
	strXML=strXML+"- <Listing>"
	strXML=strXML+"  <HardwareID>3</HardwareID> "
	strXML=strXML+"  <Manufacturer>Sony</Manufacturer> "
	strXML=strXML+"  <Product>Vaio</Product> "
	strXML=strXML+"  </Listing>"
	strXML=strXML+"  </Hardware>"

	
	
	objSource.async = false
	objSource.loadXML strXML  
 
	'retrieve data for table OR report eof
	If ((objSource.readyState = 4) AND (objSource.parseError.errorCode = 0)) Then
		Set rootElement = objsource.documentElement  'for shorter xmldom calling
	
		if rootelement.getElementsByTagName("listing").length-1=0 then  'check if rst is empty
%>		
Your Search did not find any matching records. Please press back button to try again
<%
		else 'records found, build select
%>

<form name="form1">
     <select name="select1">
<%
				
		   for i=0 to rootelement.getElementsByTagName("listing").length-1        'go through the xml
		
		    	hardwareid=rootelement.getElementsByTagName("listing").item(i).getattribute("HardwareID") 
			manufacturer=rootelement.getElementsByTagName("listing").item(i).getattribute("Manufacturer") 
			product=rootelement.getElementsByTagName("listing").item(i).getattribute("Product") 
%>
			<option value="<%=hardwareid%>"><%=manufacturer%>, <%=product%></option>
<%

     
		    next
		end if
	end if
%>
          
     </select>
     <input type="submit" name="submit" value="submit">
</form>

Reply With Quote
  #10  
Old August 19th, 2003, 12:08 PM
aspman aspman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Ashburn,VA
Posts: 105 aspman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 22 m 40 sec
Reputation Power: 5
Don, Ok, since you said, you know how to create an xml file, I didnot think you needed this information.

Here is how the XML file is created. you can use ado's adpersistxml parameter in rs.save to get an xml file and it is quite easy to manipulate with the script I gave you below.

the name of this file is tgexistslist.asp ( src of the xml data island in the script below)

<%@ Language=VBScript %>
<%
Response.ContentType="text/xml"
%>
<!--#include file='conmanager.inc'-->
<!--#include file='getXML.inc'-->
<%
dim strSQL
dim scoloID
scoloID=Request.QueryString("coloID")
if Request.QueryString("coloID").Count=0 then
Response.Write "<xml xmlns:z=""#RowsetSchema""><z:row ID=""0"" COLO=""-N/A-"" /></xml>"
else
strSQL = "select tg.id,tg.trunkgroup"&_
" from trunkgroup_header tg"&_
" where tg.colo_id=" & scoloID &_
" order by tg.trunkgroup"
end if
response.write getXMLData(strsql,"dbconnection")


function getXMLData(strSQL, conName)
on error resume next
dim oStr, oRS, oCon, strConn, oops
Response.Write("<?xml version='1.0'?>" & vbCrLf)
set oCon = getConnection(conName)
set oRS = server.CreateObject("ADODB.Recordset")
oRS.Open strSQL, oCon
set oStr = Server.CreateObject("ADODB.Stream")
oStr.Open
oRS.Save oStr, 1
if err.number = 0 then
getXMLData = oStr.ReadText
else
oops = "<xml>"
oops = oops & "<error>Database lookup failed. Check your connection parameters and query syntax.</error>"
oops = oops & "<sqlstring><![CDATA[" & strSQL & "]]></sqlstring>"
oops = oops & "<uname>" & dbUser & "</uname>"
oops = oops & "<pass>" & dbPass & "</pass>"
oops = oops & "<tnsname>" & tnsName & "</tnsname>"
oops = oops & "</xml>"
getXMLData = oops
end if
oStr.Close
set oStr = nothing
oRS.Close
set oRS = nothing
end function



%>
<!--#include file='concleanup.inc'-->






Quote:
Originally posted by aspman
Hi Don,

here is a more simpler way of acheiving it.

The combo box that i am filling is just an INFO purpose and the length of the combo box is 5 which means users can see 5 values at a time.
We can certainly add "select one" at the top of a huge list of values.

function populatetgexstCombo(par)

{
var tgs;

//Data ISLAND to be declared in the body of the html and set it to asynchronous data read mode.
XMLtgexstID.async = false;

// Change Ddata Island source
XMLtgexstID.SRC="/<%=approot%>/data/tgexistslist.asp?coloid="+ par;

// Get recordset from XML data
var tgs = XMLtgexstID.getElementsByTagName("z:row");

// Fill combo with what is needed
for (var i=0; i < tgs.length; i++) {
if (tgs.item(i).attributes(1).text !="") {
form.combo.options[i]=new Option(tgs.item(i).attributes(1).text ,tgs.item(i).attributes(0).text);
}//end if
}//end for

// Delete extra entries
while (tgs.length < form.combo.options.length) {
form.combo.options[(step3.tgExst.options.length-1)] = null;
} //end while



}//END FUNCTION


and after the body tag in the html/asp page

add this

< XML ID="XMLtgexstID" > </XML>

---------------------------------------------------------------

Hope that helps. Let me know if you have any questions regarding the script

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > ASP using XML


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |