Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: XML to CSV in VBScript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,25624
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: XML to CSV in VBScript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 2 3 4 [5]
Login
Message << Older Topic   Newer Topic >>
 RE: XML to CSV in VBScript - 9/23/2005 8:09:22 PM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline
Hi Snipah,

Of course:) I will do that.

(in reply to Snipah)
 
 
Post #: 81
 
 RE: XML to CSV in VBScript - 9/23/2005 8:34:26 PM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline
Hi All,

How can I inherit Object or Values in a Function? (In Qbasic there was a "Common" direction what is get the specified values for the function, but what is it in VBScript?)

Somewhere on this forum I read about this.

My exactly problem, that I create a file out of the function, and I want to write in the file during the function.

(in reply to reloader)
 
 
Post #: 82
 
 RE: XML to CSV in VBScript - 9/25/2005 6:56:54 PM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline
Hi Zifter,

Could explain me, or suggesting anything document or sample, that how can I declare a varibale in a Function, and how does the function run? How can I give values to the function from the Main porgram, and reverse?


(in reply to Zifter)
 
 
Post #: 83
 
 RE: XML to CSV in VBScript - 9/25/2005 7:50:28 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
quote:

ORIGINAL: DiGiTAL.SkReAM

Wow.

I am really impressed by your patience and willingness to go the extra 15 miles to help out a stranger, Zifter.

No sarcasm, irony, or joking around on my part.  Just honest respect.

I don't think... no, I *know* that I couldn't stick with it this long.


It's not always easy to stay patient. But that is an advantage of helping people through a forum. You can first take a coffee, smoke a cigarette or two, relax and rephrase any not-so-friendly sentences...
quote:

ORIGINAL: reloader
Hi Zifter,

Could explain me, or suggesting anything document or sample, that how can I declare a varibale in a Function, and how does the function run? How can I give values to the function from the Main porgram, and reverse?
If you define a variable in your script, then that variable is known in the whole script. Also in the functions. If you define a variable in a function, then that variable is only known within the function itself.
You can pass the value of a variable to a function or you can pass (a pointer to) a variable object. You do this respectively with"ByVal" and ByRef". Check the following two examples:
      
      

You can find links to the documentation (and more) in the sticky post (http://www.visualbasicscript.com/m_24727/tm.htm)

HTH

< Message edited by Zifter -- 9/25/2005 7:51:31 PM >

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 84
 
 RE: XML to CSV in VBScript - 9/25/2005 8:06:45 PM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline
Hi Zifter,

Thanks for the fast reply, It's clear now, but what about the objects?:

(The favorite code of yours:) )


Option Explicit
Dim objXMLDoc
Set objXMLdoc = CreateObject("Msxml2.DOMDocument.5.0")
objXMLDoc.async = False

objXMLDoc.load(
"P:\audits2.xml")

fnEchoChildsAndAttributes objXMLDoc.documentElement
Set objXMLDoc = Nothing
Dim fso, Mf
Set fso = CreateObject("Scripting.FileSystemObject")

Set Mf = fso.CreateTexFile("P:\Parser4\test.txt", True)




Function
fnEchoChildsAndAttributes(objTempNode)

Dim objTempChildNode

Dim objTempAttribute
...

If I setting fso and Mf in the function, I get an error message as "Permission Denied". I think it wants to recreate, but than what is the solution, because if I setting outside the function I get an error message: "Object Required".

I think accordingly variables inherited in the function too(as u write the prev. reply), but the objects.(?)
 

(in reply to Zifter)
 
 
Post #: 85
 
 RE: XML to CSV in VBScript - 9/25/2005 8:15:46 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
You get the message "Permission Denied" when another program (could be the same script) is holding the file. You can't write to a file that is in use.
The message "Object Required" should be self explaining.

If you post your complete script, we can take a look where the error might be located. The part of the script you posted looks ok to me.

(in reply to reloader)
 
 
Post #: 86
 
 RE: XML to CSV in VBScript - 9/25/2005 8:30:40 PM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline

Hi Zifter,
 
Here is the code((error message is 'object required 'Mf' ')):

Option Explicit
Dim objXMLDoc
Set objXMLdoc = CreateObject("Msxml2.DOMDocument.5.0")
objXMLDoc.async = False

objXMLDoc.load(
"P:\audits2.xml")

fnEchoChildsAndAttributes objXMLDoc.documentElement
Set objXMLDoc = Nothing
Dim fso, Mf
Set fso = CreateObject("Scripting.FileSystemObject")

Set Mf = fso.Createtextfile("P:\Parser4\test.txt", True)




Function
fnEchoChildsAndAttributes(objTempNode)


Dim objTempChildNode

Dim objTempAttribute



 
If Not objTempNode.ChildNodes Is Nothing Then
If Not objTempNode.ChildNodes.Length = 0 Then
For Each objTempChildNode In objTempNode.ChildNodes
If IsNull(objTempChildNode.NodeValue) Then
WScript.Echo objTempChildNode.NodeName
Else
WScript.Echo objTempChildNode.NodeName & ": " & objTempChildNode.NodeValue

If objTempChildNode.NodeName <> "rth" Then Mf.WriteLine "<" & objTempChildNode.NodeName & ">"

End
If
fnEchoChildsAndAttributes(objTempChildNode)
Next
End If
End If
If Not objTempNode.Attributes Is Nothing Then
If Not objTempNode.Attributes.Length = 0 Then
For Each objTempAttribute In objTempNode.Attributes
WScript.Echo objTempAttribute.Name & ": " & objTempAttribute.Value

Mf.WriteLine "<" & objTempAttribute.Name & ">"

Next
End If
End If
End Function

(in reply to Zifter)
 
 
Post #: 87
 
 RE: XML to CSV in VBScript - 9/25/2005 8:39:28 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
You get the error message because you declare and create the two objects "fso" and "Mf" after you call the function. So the function can't 'know' these two objects.
Move those statements before the call to the function. Like this:
      

< Message edited by Zifter -- 9/25/2005 8:40:50 PM >

(in reply to reloader)
 
 
Post #: 88
 
 RE: XML to CSV in VBScript - 9/25/2005 11:40:50 PM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline
Thx Zifter,

I understand now.

My last question(for today:) ) that could explain me a compare algorythm?

In details, I have an array:

1
2
3
4
2
3
4

And I want to get every value with no repeat, so I want:

1
2
3
4

Do u have any idea for it? (I think it's a basic algorythm but I have learnt programming  for many years)

(in reply to Zifter)
 
 
Post #: 89
 
 RE: XML to CSV in VBScript - 9/26/2005 1:36:08 AM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
There are several ways of removing the duplicates out of an array.
In this case I would use a dictionary object. These objects are two dimensional kind of arrays, with the extra that they don't allow duplicate items.
So you define a dictionary object.
Try to add each element of the array to this dictionary object.
When you try to add an element that is already in the dictionary, an error will be raised. You can skip this error raising by putting "On Error Resume Next" and "On Error Goto 0" around the filling of the dictionary object.
Here is a small example.
      

(in reply to reloader)
 
 
Post #: 90
 
 RE: XML to CSV in VBScript - 9/26/2005 5:41:30 PM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline
Thx Zifter,

It's very simple and usable, but how can I modified this code, if I want do something with the duplicate values? For intances:

1
2
3
2
3
3

If there is the second "2" value change this to "2(45)", and so on with "3". . .

(in reply to Zifter)
 
 
Post #: 91
 
 RE: XML to CSV in VBScript - 9/27/2005 12:34:29 AM   
  reloader

 

Posts: 72
Score: 0
Joined: 9/5/2005
Status: offline
Okay, I solved it, (so-so)

I write here, maybe it will help somebody in similar case:

Dim a(10)
Dim b(10)

a(1)="1"
a(2)="2"
a(3)="2"
a(4)="3"
a(5)="1"
a(6)="3"
a(7)="5"

For i= 1 To 7
e=0
For x= i+1 To 7
e=e+1
If a(i) = a(x) Then
       a(i)=a(i) & "("& e &")"
End If
Next
Next
for i1 = 1 to 7
wscript.echo a(i1)
Next

It's absolutely not complicate, only has to some little traps.

(in reply to reloader)
 
 
Post #: 92
 
 Differentiate XML's values using XSL - 5/17/2007 6:01:39 PM   
  rudrarup


Posts: 58
Score: 0
Joined: 5/26/2005
From: Pune
Status: offline
Sorry to budge into this post, but the post looks to be more relevent to what I require.
 
I have auto generated XML file and related XSL file
 
XML
<?xml version="1.0" encoding="utf-8"?>
<Class>Part<LDI>Gear<Available>TRUE</Available></LDI></Class>

 
XSL
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>
<font face="Trebuchet MS">
<table border="0" width="100%">
      <tr bgcolor="#99cc99">
       <td><h4>Part:<xsl:value-of select="Class/LDI"/></h4></td>
      </tr>
</table>
</font>
</body>
</html>
</xsl:template></xsl:stylesheet>

 
I am using basic VBS file to  auto generate html files from the XML files using XSL files
 
I require the output as
Part:Gear
But the actual output the code is giving is
Part:GearTRUE
 
Can anybody tell me or supply any resource so as how to edit the XSL file to get the expected  output.

_____________________________

Be content. Have the sporting spirit.
Trishanku.

(in reply to Snipah)
 
 
Post #: 93
 
 RE: Differentiate XML's values using XSL - 5/23/2007 7:40:58 PM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi rudrarup,

try:

<td><h4>Part:<xsl:value-of select="Class/LDI/text()"/></h4></td>

Good luck!

ehvbs

(in reply to rudrarup)
 
 
Post #: 94
 
 
Page:  <<   < prev  1 2 3 4 [5]
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: XML to CSV in VBScript Page: <<   < prev  1 2 3 4 [5]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts