|
|
|||||||
Hi All, I've got about 180 x 2003 servers running a script and I would like to fine tune the parameters they are using. I was thinking about having a central XML file on a web server or a ini file. How do I go about getting it to read a file from the Internet/intranet as apposed from a local file system? Tried somthing like this but dont get any output: Code: $xml = LoadXml("http:\\localhost\test.xml") $id = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/id") $name = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/name") $gender = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/gender") $age = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/age") $place = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/place") $province = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/province") $date_membership = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/date_membership") $url_profile = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/url_profile") $url_photothumb = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/url_photothumb") $advert_title = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/advert_title") $advert_description = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/advert_description") ? $id ? $name ? $gender ? $age ? $place ? $province ? $date_membership ? $url_profile ? $url_photothumb ? $advert_title ? $advert_description Function ReadXmlValue($xml, $key, optional $defaultValue) Dim $sectionNode $sectionNode = $xml.SelectSingleNode($key); If Not $sectionNode $ReadXmlValue = $defaultValue Else $ReadXmlValue = $sectionNode.FirstChild.Text; EndIf EndFunction Function LoadXml($filename) Dim $rootNode $loadXml = CreateObject("Microsoft.XMLDOM") If Not $loadXml Return EndIf $= $loadXml.Load($filename) EndFunction Darren |
||||||||
|
|
|||||||
Reading an XML is a pain with kix. I did some stuff with it and most of the times the output is empty. Did not find anything that solves this in kix. An ini file is real easy to read with kix. An example. Script. Code: Break on $inifile = "\\server\share\inifile.ini" $pfilesizeserver1 = ReadProfileString($inifile, "Server01", "Pagefilesize") ?$pfilesizeserver1 $pfilesizeserver2 = ReadProfileString($inifile, "Server02", "Pagefilesize") ?$pfilesizeserver2 Sleep 3 inifile: Code: [server01] Pagefilesize=1234567890 [server02] Pagefilesize=1122334455 This just an example so it shows 1234567890 and 1122334455 on your screen and does nothing to specific server. |
||||||||
|
|
|||||||
Guess this is a bit where COM Scripting comes in Code: Dim $xmlDoc, $objNodeList, $plot $xmlDoc = CreateObject("Msxml2.DOMDocument") $xmlDoc.load("c:\inetpub\wwwroot\test.xml") $objNodeList = $xmlDoc.getElementsByTagName("description") If $objNodeList.length > 0 For each $x in $objNodeList $plot = $x.Text ? $plot Next Else ? chr(34) + "description" + chr(34) + " field not found." EndIf This is just something I quickly translated from the web, just search google for Microsoft.XMLDOM |
||||||||
|
|
|||||||
Humm, I would like to read it from a webserver, I'm just testing it on a local install of apache as below using "http://localhost/inifile.ini" but dont get anything, what is the correct syntax to do this? code: Code: Break on $inifile = "http://localhost/inifile.ini" $pfilesizeserver1 = ReadProfileString($inifile, "Server01", "Pagefilesize") ?$pfilesizeserver1 $pfilesizeserver2 = ReadProfileString($inifile, "Server02", "Pagefilesize") ?$pfilesizeserver2 Sleep 3 Darren |
||||||||
|
|
|||||||
COM would work for XML but all it gave me is a headache. I used scripts from several threads on this board and for some weird reason they can read some xml files but on other files with the same layout and encoding they fail. XML is getting bigger and bigger so maybe it is time for some proper XML support in kix. A web server cannot serve an ini file like it can an html/asp/php, etc.... file. If it is localhost then why not just use \\server\share\inifile.ini? |
||||||||
|
|
|||||||
No, its not going to be on the localhost, but on a remote server (Intranet), just running a local webserver to test it out. D |
||||||||
|
|
|||||||
Well without using some type of other remote connection method the actual Web Server is not going to allow you to output that from a central location. You might be able to modify registry settings etc to force it but then you also might be compromising security of the system. If it HAS to be read via the Web Serving feature then you may have to look elsewhere than KiX as it has no intrinsic feature that I'm aware of to allow interfacing with a Web Server. You can also read stuff using WMI if wanted, but I think you probably have something else in mind if the COM method isn't good for you and SMB isn't good for you. Not really sure what else to offer for your project. There are some XML UDFs in the UDF forum you can look at and see if you can get them to do what you're wanting. |
||||||||
|
|
|||||||
One could use CreateObject("Microsoft.XMLHttp") to download the file locally and read it out from there. For instance Code: Dim $xml, $get $xml = CreateObject("Microsoft.XMLHTTP") $xml.Open("GET","http://www.somesite.org/news.xml",Not 1) $xml.Send $get = CreateObject("ADODB.Stream") $get.Mode = 3 ;adModeReadWrite $get.Type = 1 ;adTypeBinary $get.Open $get.Write($xml.ResponseBody) $get.SaveToFile("C:\temp.xml",2) ;2 is adSaveCreateOverwrite $get.Close $get = "" $xml = "" |
||||||||
|
|
|||||||
I thought he said he didn't want to do it locally ? (didn't reread entire thread) |