|
-
Jan 15th, 2009, 10:46 AM
#1
Thread Starter
New Member
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>
-
Jan 15th, 2009, 11:00 AM
#2
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.
-
Jan 15th, 2009, 11:04 AM
#3
Thread Starter
New Member
Re: How to convert XML to CSV using vb.net
Thanks for quick response.
I got an error. The XMl has prefix (<my:FN>...)
 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.
-
Jan 15th, 2009, 04:01 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|