Extracting email addresses from an XML document (Hello BlueDevilFan!)

Posted on 2005-05-12
Last Modified: 2010-04-08
Hello all:

I am trying to extract the email addresses from an xml file.  Here is what it looks like:

<?xml version="1.0" encoding="utf-8" ?>
      <email></email><name>Chris Cooper</name><at>SMTP</at><source>3</source><ld>481272848</ld><hd>29606945</hd><ldlu>481272848</ldlu><hdlu>29606945</hdlu><tu>1</tu>
      <email></email><name>Angus Laverty</name><at>SMTP</at><source>1</source><ld>2490327632</ld><hd>29601702</hd><ldlu>3738936032</ldlu><hdlu>29681508</hdlu><tu>3</tu>
      <email></email><name>Maura Bannon</name><at>SMTP</at><source>3</source><ld>1447033616</ld><hd>29611749</hd><ldlu>1447133760</ldlu><hdlu>29611749</hdlu><tu>1</tu>

The file is 1.2 Megs big.  I am looking at just pulling what is between the <email> and </email> tags and storing them in a simple .txt file, one address per line.

Could someone please help me out with this?

Indebted to you.

Question by:driven13
    LVL 13

    Accepted Solution

    Are these real addresses? Welcome to spambot2000, yum yum :)

    Add this to your xml file (right below your first line):
    <?xml-stylesheet type="text/xsl" href="data.xsl" ?>

    then make the data.xsl (in the same folder as your xml file):
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <html xsl:version="1.0" xmlns:xsl="" xmlns="">
      <body >
        <xsl:for-each select="contents/addr">
            <p><xsl:value-of select="email"/></p>

    Now open the xml file in IE -- presto! List of emails! :)
    LVL 13

    Expert Comment

    If you want to save it, just copy+paste into a notepad file.

    Author Comment

    Thank you softplus!!

    That worked perfectly.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Sorry for my English and Italian screenshots..... Problem: Every Year the number of E-Mails grow dramatically and the space that they take on Exchange Servers or .PST files, grow much more faster, once it was only text, now our E-Mail Archives …
    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now