Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 21st, 2006, 04:12 AM
Registered User
Points: 25, Level: 1
Points: 25, Level: 1 Points: 25, Level: 1 Points: 25, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to extract THIS node from XML in ASP??

Hi

My first task was to : extract country code and country name values in a combo box:

I did this and here is my code:

====================================
'ASP Code start here:

Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
     objXMLDoc.async = False
     objXMLDoc.loadXML("countries.xml")


Response.Write "<form action='getCity.asp' method='post'>"

%>
<select name="txtCountryID" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
<%

     'Response.Write "<option value='' selected>Select Country</option>"

     Set NodeList2 = objXMLDoc.getElementsByTagName("CoID")
     Set NodeList = objXMLDoc.getElementsByTagName("Country")


     numNodes2 = NodeList2.Length

     For i = 1 To NumNodes2
             Set CurrNode2 = NodeList2.nextNode
             Set CurrNode = NodeList.nextNode
             Response.Write "<option value='getCity.asp?CountryID="&CurrNode2.text&"&Co untry="&CurrNode.text&"'>"&CurrNode.text&"</option>"
     Next

     Response.Write "</select>"
     Response.Write "</form>"
'Asp Code End here
============================================


============================================
'short version of my XML file
<?xml version="1.0" encoding="utf-8" ?>
- <CountriesCities>
- <Countries>
  <CoID>111</CoID>
  <Country>ALBANIA</Country>
  <Cities CiID="1478" City="TIRANA" />
  </Countries>
- <Countries>
  <CoID>1</CoID>
  <Country>AUSTRALIA</Country>
  <Cities CiID="1" City="ADELAIDE" />
  <Cities CiID="4" City="MELBOURNE" />
  <Cities CiID="6" City="SYDNEY" />
  </Countries>
- <Countries>

'XML file end here
============================================

Until here I am fine.

My problem is:

I have now the countries in the combo on the first page. On the next page, I want another combo, with the cities from selected country.


Clarification: if on the first page selected country was Albania, I would like to get Tirana only in my combobox, and if selected country was Australia to get: ADELAIDE, MELBOURNE and SYDNEY

The very same as in the country combo, ID is the value and the name is displayed in the combo.

Anyone can help?

Thanks, Zoreli

  #2 (permalink)  
Old July 21st, 2006, 09:51 AM
Registered User
Points: 25, Level: 1
Points: 25, Level: 1 Points: 25, Level: 1 Points: 25, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I solve this part and just in case that anyone may need this solution here it is:
================================================== ======
Set states = objXMLDoc.getElementsByTagName("Cities")
n_states = states.length

For i = 1 To n_states

Set state = states.NextNode
attr = state.getAttribute("CiID")
attr2 = state.getAttribute("City")
Response.write(attr +"&nbsp;"+ attr2 + "<br>")
Next
================================================== ======
But Now, I have other problem to solve. How can I select
Cities where Country code is for example 111? Anyone can help me with this?

Here is the sample of my XML file:

<?xml version="1.0" encoding="utf-8" ?>
- <CountriesCities>
- <Countries>
  <CoID>111</CoID>
  <Country>ALBANIA</Country>
  <Cities CiID="1478" City="TIRANA" />
  </Countries>
- <Countries>
  <CoID>1</CoID>
  <Country>AUSTRALIA</Country>
  <Cities CiID="1" City="ADELAIDE" />
  <Cities CiID="4" City="MELBOURNE" />
  <Cities CiID="6" City="SYDNEY" />
  </Countries>
- <Countries>




Similar Threads
Thread Thread Starter Forum Replies Last Post
how to append child node after an node in XML + C# vishnu108mishra XML 5 November 13th, 2007 05:30 AM
Extract the XML file from CDATA haixia XSLT 2 August 3rd, 2006 02:01 PM
Extract data and create xml for input dhol General .NET 1 February 2nd, 2005 03:01 PM
Extract Data From Node ryanpatrick XML 1 February 18th, 2004 10:31 AM
extract xml using asp daddycool2k Classic ASP XML 0 November 17th, 2003 12:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.