Link to home
Create AccountLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

how to convert space into under score and vice versa

Hello Experts,

I am posting some information(data) to the proxy.asp which would accept the data being sent and saves into the XML file.
Later in the application I pull the details matching with one of the node, name, this works as long as if there is only one word name.
If I have the space in the name then it is breaking.
Can someone please advice how to convert the spaces into underscore before the saving it into the xml file?

 

I hope someone can help.

thanks
sam
Avatar of newbie27
newbie27
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

this is the function i am using to save the file,

i am concerned for this

Set objListItem = objXML.createElement("listname")
                objListItem.text = CleanXML(sListName)
                objList.appendChild objListItem
 sXMLFile = ADMIN_WWW_FOLDER & "\lists\data\" & sFilename        
    
 	Set objXML = Server.CreateObject("Microsoft.XMLDOM")
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
	
	
		If Not fso.FileExists(sXMLFile) Then
                Set objRoot = objXML.createElement("lists")
                objXML.appendChild objRoot
                
                Set objUser = objXML.createElement("username")
                objUser.text = "test@test.com"
                objRoot.appendChild objUser
				
                Set objPI = objXML.createProcessingInstruction("xml", "version=""1.0"" encoding=""UTF-8""")
                objXML.insertBefore objPI, objXML.childNodes(0)
                objXML.save sXMLFile
        End if
 
        objXML.load(sXMLFile)
        Set objRoot = objXML.documentElement
 
        Set oNodes = objXML.selectNodes("//lists/*")
       
            Set objList = objXML.createElement("listitem")
                objRoot.appendChild objList
 
            Set objListItem = objXML.createElement("listname")
                objListItem.text = CleanXML(sListName)
                objList.appendChild objListItem
        
            Set objListItem = objXML.createElement("listnotes")
                objListItem.text = CleanXML(sNotes)
				objList.appendChild objListItem
        
            Set objListItem = objXML.createElement("listrefs")
                objListItem.text = strListISBNs
                objList.appendChild objListItem
			
			Set objListItem = objXML.createElement("itemnotes")
                objListItem.text = sItemNotes
                objList.appendChild objListItem	
 
            Set objListItem = objXML.createElement("last_updated")
                objListItem.text = Year(Now()) & PadZ(Month(Now()),2) & PadZ(Day(Now()),2) & "|" & PadZ(Hour(Now()),2) & ":" & PadZ(Minute(Now()),2) & ":" & PadZ(Second(Now()),2)
                objList.appendChild objListItem
				
				
			 
     
		
 
        objXML.save sXMLFile

Open in new window

Avatar of Guy Hengel [angelIII / a3]
which "names" do you refer to?
coming from this question, please clarify the data you mean.
https://www.experts-exchange.com/questions/23556943/deleting-data-from-the-xml-file.html?anchorAnswerId=22017658#a22017658)
Hello angelll,

thanks for looking this for me, If you please see the attached xml file, I am referring to

testall

if it is test all with space between, i would like to make it as test_all

ex: test_all

does this makes any sense to you angellll ?


<lists>
<username>test@test.com</username>
<listitem>
<listname>testall</listname>
<listnotes>testing</listnotes>
<listrefs>
e2007092018174409,e2007091011024965,e2007091011113098
</listrefs>
<itemnotes>null,null,null</itemnotes>
<last_updated>20080716|16:52:48</last_updated>
</listitem>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Hello Angellll,
Thanks for your comment.
Well it seems to me that these spaces does matter when I pull them and show in the drop down list box, user can select the name from the list and view their details in the Flexigrid on the page.
I also have another field called "notes" which are associated with the listRefs in the xml file.

http://213.253.134.6/artism/admin/list_admin.asp#testall

if you please go to this page, and from the SELECT you can either testAll and test All and see the difference ...
if you have space in the name, although there is different value in the notes field
http://213.253.134.6/artism/admin/lists/data/test@test.com.xml
it is not showing in the grid, you can also add your own notes and save the record ( ignore the over write warning and save it) to see that for other list it works as normal but not not for the one with space...

hope you see what i am trying to say you here?

i have another jQuery issue on the page, do you think you can help me on the Facebox as well please?

FUNCTION CleanXML(T)
	
	T = Replace(T, "&amp;", "##38;")
	T = Replace(T, "&apos;", "##39;")
	T = Replace(T, "&quot;", "##34;")
	T = Replace(T, "&lt;", "##60;")
	T = Replace(T, "&gt;", "##62;")
	T = Replace(T, "&#", "##")
	T = Replace(T, "&", "&#38;")
	T = Replace(T, "##", "&#")
	
	T = Replace(T, "<", "&#60;")
	T = Replace(T, ">", "&#62;")
	T = Replace(T, "£", "&#163;")
 
	T = Replace(T, VbCr, ",")
	T = Replace(T, VbLf, ",")
	T = Replace(T, VbCrLf, ",")
	T = Replace(T, ",,", ",")
	
	'T = Replace(T, chr(150), "-")
	'T = Replace(T, chr(145), "&#39;")
	'T = Replace(T, chr(146), "&#39;")
	'T = Replace(T, chr(133), "...")
	
	CleanXML = Trim(T)
	
END FUNCTION
'###############################################################################

Open in new window

angelll,
i have use your code and have replace all the spaces as that was spoiling other things...

please can you help me in my other jQuery issues angellll?
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23569037.html
 
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23565966.html
 
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23570227.html
 
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_23569316.html

Open in new window

thanks