LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-10-2004, 09:54 PM   #1
Kedelfor
Member
 
Registered: Jan 2004
Posts: 49

Rep: Reputation: 15
XML and XSL


Let me start by explaining what I want to do.

I use nmap -sP x.x.x.* -oX to creat an XML document of all the IPs that are up. That works fine. Next I added in the line so that my XML sorce is pointing to my XLS file. Then I want it to show all the Ips that are up thats all. I will post my source so you can take a look at it. I can get it to select correctly I think, but can not print the attribute I want.


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<center>
<h2>IPs that are Up</h2>
<table border="1">
<tr>
<th>IP Address</th>
</tr>
<xsl:for-each select="/nmaprun/host/status[@state='up']">
<tr>
<td><xsl:value-of select="//address[@addr]" /> </td>
</tr>
</xsl:for-each>
</table>
</center>
</body>
</html>
</xsl:template>

</xsl:stylesheet>
 
Old 09-11-2004, 02:30 AM   #2
Archite
Member
 
Registered: Jul 2004
Distribution: OpenBSD 3.5
Posts: 89

Rep: Reputation: 15
Can you provide a sample of your xml doc?
 
Old 09-11-2004, 09:48 AM   #3
Kedelfor
Member
 
Registered: Jan 2004
Posts: 49

Original Poster
Rep: Reputation: 15
This is part of the XML source

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="nmap.xsl"?>
<!-- nmap 3.50 scan initiated Fri Sep 10 19:24:13 2004 as: nmap -sP -oX /var/www/htdocs/nmap.xml 67.165.48.* -->
<nmaprun scanner="nmap" args="nmap -sP -oX /var/www/htdocs/nmap.xml 67.165.48.*" start="1094858653" version="3.50" xmloutputversion="1.0">
<verbose level="0" />
<debugging level="0" />
<host><status state="down" />
<address addr="67.165.48.0" addrtype="ipv4" />
</host>
<host><status state="up" />
<address addr="67.165.48.1" addrtype="ipv4" />
<hostnames><hostname name="c-67-165-48-1.client.comcast.net" type="PTR" /></hostnames>
</host>
<host><status state="up" />
<address addr="67.165.48.2" addrtype="ipv4" />
<hostnames><hostname name="c-67-165-48-2.client.comcast.net" type="PTR" /></hostnames>
</host>
<host><status state="down" />
<address addr="67.165.48.3" addrtype="ipv4" />
</host>
 
Old 09-11-2004, 08:02 PM   #4
Archite
Member
 
Registered: Jul 2004
Distribution: OpenBSD 3.5
Posts: 89

Rep: Reputation: 15
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<center>
<h2>IPs that are Up</h2>
<table border="1">
<tr>
<th>IP Address</th>
</tr>
<xsl:for-each select="/nmaprun/host/status[@state='up']">
<tr>
<td><xsl:value-of select="//address/@addr" /> </td>
</tr>
</xsl:for-each>
</table>
</center>
</body>
</html>
</xsl:template>

</xsl:stylesheet>
 
Old 09-13-2004, 05:30 PM   #5
Kedelfor
Member
 
Registered: Jan 2004
Posts: 49

Original Poster
Rep: Reputation: 15
Thank you, but I tried it, and it prints the ips, but they all end in .0

67.165.48.0
67.165.48.0
67.165.48.0
67.165.48.0
67.165.48.0
This is the ouput. Thank you for your help again. Is there something else that needs to be done?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help to strip XML & XSL tags from multiple files dfrechet Programming 9 10-12-2005 06:52 AM
XSL need help translating XML to html hyperlink qwijibow Programming 1 03-09-2005 04:36 PM
Docbook XSL Stylesheets /etc/xml/catalog Ironica Linux - Software 0 12-10-2004 03:03 AM
xml parsing with xsl crabboy Programming 2 03-22-2004 01:45 AM
Xerces, Xalan -- XML + XSL = HTML marktaff Linux - Software 1 10-15-2002 10:01 PM


All times are GMT -5. The time now is 05:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration