Parse command not working on XML file
I have a Wise Script and I have to Read/Update a file and place what it reads in a variable called %READ%. I then PARSE %READ% but it does not find what I am looking for. I am reading a ,XML file and it does not find what I tell it to find. Parse alwasy works when I run it on a .TXT file so does it not work on XML files? We are using WPS 7.x.
I did read this in the online help.
You can split the string at a character or substring that you specify, which discards the character or substring you specified. Example: If you split the string "ONE,TWO" at the first occurrence of a comma, "ONE" is put into destination variable 1 and "TWO" is put into the destination variable 2. If the character or substring is not found, the entire string is put into destination variable 1, and nothing is put into destination variable 2. The find is case-sensitive.
It says "If the character or substring is not found, the entire string is put into destination variable 1" and that is exactly what is happening with my code. I put in "Display Message" commands to see this.
And if I rename my XML file to .TXT it still does not work since the formatting is all messed up. But when I Parse any other .TXT it works as it should. So can Wise Parse XML files properly?
Parsing XML Files...
The Windows Installer Editor has a mechanism for parsing XML files. In the Windows Installer Editor (Installation Expert View), make sure that you have the correct feature selected that the xml file is im, choose the file view, select the XML file, and then choose "details". On the dialouge that appears, choose the tab "Dynamic Content", there you can select the checkbox "Enable Dynamic Content" and you can set the various elements within the XML file dynamically using properties.
Cheers
Phil
p.s.
As with any XML file, it should be a valid XML file. To check this, open it up in the IE, and if it opens it OK, then the file should be alright.
Thanks for the tip but you
Thanks for the tip but you did not see where I wrote: "I have a Wise Script". This is not a MSI I am dealing with but a .wse file.
Thanks.
Then you will
have to use VBS. Wise Script does not support (nativly) parsing XML files. As you never know how they are going to be formed. Another method would be to create a custom.dll that contains XML parsing capabilites, and then call that from your WSE script.
Cheers
Phil
What is the problem you are experiencing?
The XML file is presumably a text file with no characters outside the standard 0-127 decimal ascii code?
In that case, your Read/Update command should be able to read the XML file a line at a time, like any other text file, and you can then parse it at any alphanumeric point.
Is it the parse logic that is not working, or are you looking for specific strings and hoping that case is ignored (NEVER ignore case unless the wise command offers an "ignore case" option).
So to take this further, we need SPECIFIC examples of what you are trying to do and what is not working.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
XML is not alwayws "text"
Hi EdT, as you probably know, xml is not always text. Dependant on how the non printable characters are coded this could lead to problems. On top of that you may have binary data also in the XML, so...
Best bet is a dll CA, short and simple (if the "aufwand" is justified).
Cheers
Phil
Can't WiseScript use function
Can't WiseScript use function calls in DLLs? If it can, the OP could perhaps research using MSXML[whatever_version].DLL's APIs to manipulate the file "properly".
Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.
Flogging a dead horse
Sometimes, it's just not worth trying to fit a square peg into a round hole, as vbscript or another scripting tool is often a far better and more efficient editing mechanism for situations such as this. Assuming WIS7 Studio is being used, I believe the wisescript editor can interface directly with vbscript, so that offers an alternative path.
Frankly, unless you are a pointy head programmer with the obligatory beard and sandals, creating DLL calls with Wisescript is best avoided unless you like a *real* challenge or are being paid by the hour....;-)
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
WiX / XML updates
I found the best method for editing XML is using the EXECXML CA's from WiX
they allow for full xpath searching and replacement.
adding nodes, deleting nodes and the list goes on. Easiest way to get the info is create an MSI in wix and extract the table as IDT and import into wise then move across the respective dll's etc.
It says "If the character or
It says "If the character or substring is not found, the entire string is put into destination variable 1" and that is exactly what is happening with my code. I put in "Display Message" commands to see this
So everytime I read the .XML file every line shows up in the first VAR.
So what I did is I coded a parse routine in WinBatch and that worked.
Would you like to reply?
Login or Register to post your comment.