Member
Join Date: May 2013
Location: Haifa, Israel
Posts: 54
|
Well ... as standard the XML should ignore anything not inside the tags, so not sure what's happening.
It could be that RW is running some checksum/Hash on the file to verify it, but then it would trip on any edit. As to viewing the characters in Notepad++ [View] [Show Symbol] [Show all characters] Reformatting XML in Notepad++ - install the XML plug in then do [Pretty print... ] various option there Last edited by Avi; February 16th, 2017 at 11:11 AM. |
#11 |
Senior Member
Join Date: Oct 2014
Location: Chicago, IL
Posts: 1,690
|
Quote:
my Realm Works videos https://www.youtube.com/channel/UCZU...4DwXXkvmBXQ9Yw |
|
#12 |
Senior Member
Join Date: Dec 2013
Posts: 798
|
Also you could try to strip special characters via regexp outside of the tags... I would need to try it out in order to provide a regexp, but usually thinks like that could be done. I don't know if that can be used then in your script but it should be possible.
http://www.regular-expressions.info/powershell.html Join the (unofficial) Realm-Works IRC Chat: #realm-works on the Rizon Network (https://wiki.rizon.net/index.php?title=Servers) -> Browser Client: https://kiwiirc.com/client/irc.rizon.net |
#13 |
Senior Member
Join Date: Dec 2013
Posts: 798
|
maybe just try to replace certain special characters first to see if only tabs / carriage returns are disturbing? Maybe it makes a difference in which codepage you store the file windws/unix/utf ecetera...
Join the (unofficial) Realm-Works IRC Chat: #realm-works on the Rizon Network (https://wiki.rizon.net/index.php?title=Servers) -> Browser Client: https://kiwiirc.com/client/irc.rizon.net |
#14 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
Quote:
Right now, my biggest issue is why PowerShell keeps reading an empty <contents /> element as a string instead of an XML element. I've tried various suggestions I've found online to do things a different way, but none have worked yet. |
|
#15 |
Senior Member
Join Date: Oct 2014
Location: Chicago, IL
Posts: 1,690
|
It has to be <contents/> Just as XML is supposed to ignore whitespace outside of tags it does not ignore it inside of tags.
my Realm Works videos https://www.youtube.com/channel/UCZU...4DwXXkvmBXQ9Yw |
#16 |
Senior Member
Join Date: Mar 2013
Location: Greater London, UK
Posts: 2,623
|
Quote:
I can confirm that RealmWorks doesn't care about blank space. I have been providing it with the nicely indented XML files for a long time without any problems. Your editor must be making some fundamental error in the XML file for it to fail to load into RW. |
|
#17 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
Quote:
Code:
</category_global></structure><contents /></export> Either way, when Powershell reads that node, it sees it either as an empty string or a null value, depending on how I read it (dot notation vs. xpath), and it won't let me do anything XML-ish with it. I'm going to be using categories anyway, so I could just create those categories in the file I'm going to modify, and let that be the end of it, but there's still that part of me that says there has GOT to be a way to do this. |
|
#18 |
Senior Member
Join Date: Oct 2014
Location: Chicago, IL
Posts: 1,690
|
Either there is something fishy with the editor you're using, seems likely according to Farling, or there is something wrong with the Powershell parser as compared to the XML standard which is also possible.
my Realm Works videos https://www.youtube.com/channel/UCZU...4DwXXkvmBXQ9Yw |
#19 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
Quote:
I just found a way to force it to read it as an object, and it's parsing it correctly now. As much as I like PowerShell, it does have its quirks. Variable types are dynamic. It doesn't have a clean, clear, reliable way to say, variable x will always be a string, and variable y will always be an integer. It does it on the fly. In many cases, that's convenient, and in many cases, it's absolutely frustrating. For anyone who's curious, instead of doing this: Code:
$contents = $RWExportData.export.contents Code:
$contents = $RWExportData.export.ChildNodes | Where-Object {$_.name -eq "contents"} |
|
#20 |
Thread Tools | |
Display Modes | |
|
|