| 1. |
Solve : help with cmd script? |
|
Answer» hello download gawk for windows, then use this gawk script thanks for the reply but specifically this i can do with simple cmd script what i am looking for is a script that will be more dynamic if i am working on an xml file and have multiple properties in there and the property names are blabla and i also have a property i would want it to fill every value that in in to and there can be a dynamic number of properties and the property is already in the xml file so i dont need to create it i just need to insert the data from in to Quote thanks for the reply but specifically this i can do with simple cmd script More dynamic than what? If you already have a simple cmd script, why are you not using it? Microsoft provides an object (actually two) for traversing the nodes in a XML file, however yours is ill-formed and would choke a VBScript. For instance, judging from your post, <name> and <vir_name> are siblings. What is the parent node? Where do <DISPLAY_NAME> and <CANONICAL_NAME> logically fit into the tree? Is there a root to the tree and if so what is it. Personally I don't find Gawk to be very intuitive, but it WORKS and sometimes you need brute force instead of dynamic. Quote from: Sidewinder on April 22, 2010, 05:48:03 AM More dynamic than what? If you already have a simple cmd script, why are you not using it? hi, i have a script that does what the gawk script above but i dont really need it in most situations for example i have properties in some xml 4 Hello 1 0 0 1 1 11111111 these are most situation and the properties are build that way so what i need is a script that will take 'Hello' from and paste it in so the FINAL file will look like that Hello 4 Hello 1 0 0 1 1 11111111 putting manually a possible situation in the script will force me to write a wall of scripting and i have numerous properties in the xml that the structure are the same as above but only the property_id changes and the labeling values so what i need is that it will go trough the file and put value in thats pretty much it... thanks I had to add a ROOT node to the tree structure. The root node ties the entire file together. Quote <?xml version="1.0"?> Code: [Select]Set xmlDoc = CREATEOBJECT("Microsoft.XMLDOM") xmlDoc.Async = "False" xmlDoc.Load("c:\temp\test.xml") 'Change as needed (input XML file) Set colDisplayNodes=xmlDoc.documentElement.selectNodes("/ROOT/PROPERTY/DISPLAY_NAME") For Each displayNode in colDisplayNodes Set colCanonNodes = xmlDoc.documentElement.selectNodes _ ("/ROOT/PROPERTY " & _ "[DISPLAY_NAME = " & "'" & displayNode.text & "'" & "]/CANONICAL_NAME") For Each canonNode In colCanonNodes canonNode.text = displayNode.text Next Next xmlDoc.Save "c:\temp\Testout.xml" 'Change as needed (output XML file) Save the file with a VBS extension and run from the command prompt as cscript scriptname.vbs Can also be run from a cmd file the same way. Good luck. The XMLDOM object will realign your XML file correctly. No extra charge. |
|