954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XML to VB issue

Hi Guys,
I am currently working on a vb project. What I am trying to do is reading a XML file and saving all the data in to the Access DB. Once this is done, I read the data from the access Db and display it in the required fields in VB form.

Issue is, when i store the value in the access, a weird character is assigned before and after the data. The character is a square box with question mark in it. Also the same character displays on the VB form as well

Please help me how can I remove these characters in VB.
I am using XML reader to read xml file and using VB 2008 version.


Thank you so much

Ashwin

ashwinshenoy
Newbie Poster
18 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

I think you need to ignore the white spaces while reading from XML and storing in DB.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

thank you so much Debasisdas
Could you please tell me the syntax to ignore the space while reading the xml...
EX : abc xyz

I just want to remove the space before abc and after xyz.. But i need to preserve the space between abc and xyz


Thank you
ashwin

ashwinshenoy
Newbie Poster
18 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

1. Read what ever is in XML.
2. Clean up the data (in this case Trim should do) and store in DB.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 
Dim x As String = " abc xyz "
        x = x.TrimStart(" "c).TrimEnd(" "c)
        MsgBox(x)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

If the above code from codeorder doesn't work you could use:

'given that xmlString is the variable holding 
'the string read from <name> abc xyz </name>

Dim newString as string = xmlString.Substring(1,xmlString.Length-2)

'store newString in DB
HookDevil
Newbie Poster
23 posts since Aug 2009
Reputation Points: 13
Solved Threads: 4
 

Thank you so much guys...

ashwinshenoy
Newbie Poster
18 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: