Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Newbie help in selecting nodes

Reply
Thread Tools

Newbie help in selecting nodes

 
 
Jenna
Guest
Posts: n/a
 
      02-23-2006
I've been trying to get my head around this XML stuff and think I
understand it pretty well.

But the XML file I'm trying to use looks very different from the
examples I've seen. I don't think I'm selecting the nodes correctly.

Any suggestions or should I be looing in JS group?

XML file location: http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp

##########################################
# My Script
##########################################
<script type="text/vbscript">

set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp")

set
nodes=xmlDoc.selectNodes("/AIRPORT_STATUS_INFORMATION/Ground_Delay/ARPT/text()")

for each x in nodes
document.write("<xmp>")
document.write(x.xml)
document.write("</xmp>")
next

</script>

 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      02-24-2006
Jenna wrote:
> But the XML file I'm trying to use looks very different from the
> examples I've seen.


Looks like absolutely standard XML to me, outside of the fact that its
<Dtd_file> element is not actually a DTD reference that a normal XML
parser would recognize as meaningful. I presume it's just there as
documentation, or to assist some specific tool.

I don't use VBScript, or the Microsoft tools, so I have absolutely no
opinion on the correctness of your script. It looks like you're trying
to use an XPath to extract the content of any <ARPT> elements, and for
each of those generate the XML text syntax (not a parsed XML data
structure) to wrap that in the strings <xmp> and </xmp>. Note that since
you aren't generating anything resembling a top-level element to enclose
these, if there's more than one this won't even be correct text syntax
for an XML document.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-24-2006

Jenna wrote:


> Any suggestions or should I be looing in JS group?


If you use VBScript I don't think looking in a JS (JavaScript) group is
a good idea. For MSXML scripting questions the newsgroup
microsoft.public.xml is a good place.

> XML file location: http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp



> <script type="text/vbscript">
>
> set xmlDoc=CreateObject("Microsoft.XMLDOM")


You need to be aware that XPath is only supported in MSXML 3 and later
while Microsoft.XMLDOM is a program id that also works in IE 5 or 5.5
without MSXML 3 installed.
It is a bit difficult to make suggestions on what to do but if you
really want to use XPath then trying to create
CreateObject("Msxml2.DOMDocument.3.0")
is necessary and works in IE 6. You also need to make sure you set the
SelectionLanguage property to XPath, see the example below.

> xmlDoc.load("http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp")


With normal security settings client-side script can't load XML from
different origins so trying to access that URL with script in a HTML
document loaded from another HTTP server (e.g. http://example.com/)
might give you a permission denied or security error.

> set
> nodes=xmlDoc.selectNodes("/AIRPORT_STATUS_INFORMATION/Ground_Delay/ARPT/text()")


For the above XML

AIRPORT_STATUS_INFORMATION/Delay_type/Ground_Delay_List/Ground_Delay/ARPT/text()
seems a better XPath.


Here is a complete example that works in IE 6 if loaded in a IE zone
like trusted sites where you can access other servers:

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<title>example</title>
<script type="text/vbscript">
Sub Show (Url)
Dim XmlDoc, ArptList, Arpt, Ul, Li
Set XmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
XmlDoc.async = False
If XmlDoc.load(Url) Then
XmlDoc.setProperty "SelectionLanguage", "XPath"
Set ArptList = XmlDoc.selectNodes(_

"AIRPORT_STATUS_INFORMATION/Delay_type/Ground_Delay_List/Ground_Delay/ARPT/text()")
Set Ul = document.createElement("ul")
For Each Arpt in ArptList
Set Li = document.createElement("li")
Li.appendChild document.createTextNode(Arpt.nodeValue)
Ul.appendChild Li
Next
document.body.appendChild Ul
End If
End Sub
</script>
</head>
<body onload='Show("http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp")'>
<h1>ARPT</h1>
</body>
</html>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Jenna
Guest
Posts: n/a
 
      02-24-2006
Thanks for the replies, it's helps a lot!! After reading the replies
I'm starting to think I shouldn't try using vbscript to read this XML
file. Being that I am a newbie and am not to familiar with vbscript at
all. I'm going to try looking up some php example since that is
something U do use. But I will still try vbscript

Thanks everyone!

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting Nodes Using Subtotal of Child Nodes renfrochris@hotmail.com XML 1 08-24-2006 12:30 AM
Text nodes and element nodes query asd Java 3 05-23-2005 10:01 AM
Looking A Nodes From Within Nodes Johnny Ooi XML 10 11-14-2004 06:55 PM
selecting nodes between other nodes Timo Nentwig XML 1 06-17-2004 04:54 AM
Reality check: Is it sensible to link XML nodes to other XML nodes in the same file? gavnosis XML 0 08-02-2003 08:22 AM



Advertisments