Results 1 to 4 of 4

Thread: How to convert XML to CSV using vb.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    2

    How to convert XML to CSV using vb.net

    Hello every one,
    I have to convert xml data into csv file using vb.net
    My xml format looks like this:

    <my:Fields>
    <my:Contact>
    <my:FN>Aa</my:FN>
    <my:LN>Bb</my:LN>
    <my:Email>[email protected]</my:Email>
    </my:Contact>
    <my:Status>
    <my:Sub>Testing</my:Sub>
    <my:TDate>12/12/2008</my:TDate>
    <my:SDupStatus>
    <my:IsDup>1</my:IsDup>
    </my:SDupStatus>
    </my:Status>
    </my:Fields>

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How to convert XML to CSV using vb.net

    Welcome to the forums!

    Create your CSV 'structure' first. For example, you could have

    FirstName,LastName,Email,Sub,TDate,IsDup

    This is not what you should use, it's just an example, as you may have multiple items or more fields.

    Then load that XML into an XmlDocument and use SelectNode and SelectSingleNode (lots of XML questions today!) to get the values out. Into variables.

    Then concatenate those values into a string that represents that CSV structure, each variable corresponding to the place as decided. There's your CSV. Plonk it into a file.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    2

    Re: How to convert XML to CSV using vb.net

    Thanks for quick response.
    I got an error. The XMl has prefix (<my:FN>...)

    Quote Originally Posted by mendhak
    Welcome to the forums!

    Create your CSV 'structure' first. For example, you could have

    FirstName,LastName,Email,Sub,TDate,IsDup

    This is not what you should use, it's just an example, as you may have multiple items or more fields.

    Then load that XML into an XmlDocument and use SelectNode and SelectSingleNode (lots of XML questions today!) to get the values out. Into variables.

    Then concatenate those values into a string that represents that CSV structure, each variable corresponding to the place as decided. There's your CSV. Plonk it into a file.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How to convert XML to CSV using vb.net

    You have to remember that to get your question answered, you need to provide details. You've told us that there's an error, but you haven't told us what the error is. Unfortunately, we have no psychic abilities so we cannot read your mind and guess what the error is.

    If there's a namespace in your Xml, you'll need to use and pass an XmlNamespaceManager class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width