Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested XML #175

Open
bolte-io opened this issue Oct 5, 2021 · 2 comments
Open

Nested XML #175

bolte-io opened this issue Oct 5, 2021 · 2 comments

Comments

@bolte-io
Copy link

bolte-io commented Oct 5, 2021

Hey, I am using this sample data...

[Ship]
ids_name = 0 ;GENERATESTRRES("Heavy Lifter")
ids_info = 0 ;GENERATEXMLRES("<xml><RDL><PUSH/><TEXT> </TEXT><PARA/><TRA data="1" mask="1" def="-2"/><JUST loc="center"/><TEXT>Stats</TEXT><PARA/><TRA data="0" mask="1" def="-1"/><JUST loc="left"/><TEXT> </TEXT><PARA/><TEXT>Gun/Turret Mounts: 0/5</TEXT><PARA/><TEXT>Armor: 15000</TEXT><PARA/><TEXT>Cargo Space: 400</TEXT><PARA/><TEXT>Max Batteries/Repair Kits: 100/100</TEXT><PARA/><TEXT>Optimal Weapon Class: NA</TEXT><PARA/><TEXT>Max. Weapon Class: NA</TEXT><PARA/><TEXT>Add'l Equipment: NONE</TEXT><PARA/><PARA/><POP/></RDL></xml>")
ids_info1 = 0 ;GENERATEXMLRES("<xml><RDL><PUSH/><TRA data="1" mask="1" def="-2"/><JUST loc="center"/><TEXT>Heavy Lifter</TEXT><PARA/><TRA data="0" mask="1" def="-1"/><JUST loc="left"/><TEXT></TEXT><PARA/><TEXT>Heavy Lifters ply the space between the ground and stars.  While hardly "romantic" spacecraft, they are surprisingly tough customers in a fight.</TEXT><PARA/><POP/></RDL></xml>")
ids_info2 = 66608
ids_info3 = 0 ;GENERATEXMLRES("<xml><RDL><PUSH/><TEXT> </TEXT><PARA/><TEXT> </TEXT><PARA/><TEXT>0/5</TEXT><PARA/><TEXT>15000</TEXT><PARA/><TEXT>400</TEXT><PARA/><TEXT>100/100</TEXT><PARA/><TEXT>NA</TEXT><PARA/><TEXT>NA</TEXT><PARA/><TEXT>NONE</TEXT><PARA/><POP/></RDL></xml>")
ship_class = 2
nickname = ge_lifter2
</source>
</data>

Currently, the XML2JS functionality strips out the XML, I need to keep it as above as a string, is this possible with some option I am not recognising?

@bolte-io
Copy link
Author

bolte-io commented Oct 5, 2021

To clarify, the XML file/script I am attempting to parse is an XML document, with sections of INI files inside the tags.

<script>
<scriptversion>
1.3
</scriptversion>

<data file="data\ships\shiparch.ini" method="append"> 
<source>
[Ship]
ids_name = 0 ;GENERATESTRRES("Heavy Lifter")
ids_info = 0 ;GENERATEXMLRES(";GENERATEXMLRES("<xml><RDL><PUSH/><TEXT> </TEXT><PARA/><TRA data="1" mask="1" def="-2"/><JUST loc="center"/><TEXT>Stats</TEXT><PARA/><TRA data="0" mask="1" def="-1"/><JUST loc="left"/><TEXT> </TEXT><PARA/><TEXT>Gun/Turret Mounts: 0/5</TEXT><PARA/><TEXT>Armor: 15000</TEXT><PARA/><TEXT>Cargo Space: 400</TEXT><PARA/><TEXT>Max Batteries/Repair Kits: 100/100</TEXT><PARA/><TEXT>Optimal Weapon Class: NA</TEXT><PARA/><TEXT>Max. Weapon Class: NA</TEXT><PARA/><TEXT>Add'l Equipment: NONE</TEXT><PARA/><PARA/><POP/></RDL></xml>")")
ids_info1 = 0 ;GENERATEXMLRES("Info2")
ids_info2 = 66608
ids_info3 = 0 ;GENERATEXMLRES("Info3")
ship_class = 2
nickname = ge_lifter2
</source>
</data>

<data file="data\ships\ships.ini" method="replace"> 
<source>
[Ship]
ids_name = 0 ;GENERATESTRRES("Heavy Lifter")
ids_info = 0 ;GENERATEXMLRES("<xml><RDL><PUSH/><TEXT> </TEXT><PARA/><TRA data="1" mask="1" def="-2"/><JUST loc="center"/><TEXT>Stats</TEXT><PARA/><TRA data="0" mask="1" def="-1"/><JUST loc="left"/><TEXT> </TEXT><PARA/><TEXT>Gun/Turret Mounts: 0/5</TEXT><PARA/><TEXT>Armor: 15000</TEXT><PARA/><TEXT>Cargo Space: 400</TEXT><PARA/><TEXT>Max Batteries/Repair Kits: 100/100</TEXT><PARA/><TEXT>Optimal Weapon Class: NA</TEXT><PARA/><TEXT>Max. Weapon Class: NA</TEXT><PARA/><TEXT>Add'l Equipment: NONE</TEXT><PARA/><PARA/><POP/></RDL></xml>")
ids_info1 = 0 ;GENERATESTRRES("Info2")
ids_info2 = 0 ;GENERATESTRRES("Info3")
ids_info3 = 0 ;GENERATEXMLRES("Info4")
ship_class = 2
nickname = ge_lifter2
</source>
</data>

</script>

I would like to be able to parse the document and strip out the INI data intact without it being parsed by the XML parser.

@bolte-io
Copy link
Author

bolte-io commented Oct 6, 2021

I also tried converting the extracted XML back from JSON to XML.
It is not identical:

Original XML:

<xml><RDL><PUSH/><TEXT></TEXT><PARA/><TRA data="1" mask="1" def="-2"/><JUST loc="center"/><TEXT>Stats</TEXT><PARA/><TRA data="0" mask="1" def="-1"/><JUST loc="left"/><TEXT> </TEXT><PARA/><TEXT>Gun/Turret Mounts: 0/5</TEXT><PARA/><TEXT>Armor: 15000</TEXT><PARA/><TEXT>Cargo Space: 400</TEXT><PARA/><TEXT>Max Batteries/Repair Kits: 100/100</TEXT><PARA/><TEXT>Optimal Weapon Class: NA</TEXT><PARA/><TEXT>Max. Weapon Class: NA</TEXT><PARA/><TEXT>Add'l Equipment: NONE</TEXT><PARA/><PARA/><POP/></RDL></xml>

and now the converted output:

<RDL><PUSH></PUSH><TEXT></TEXT><TEXT>Stats</TEXT><TEXT></TEXT><TEXT>Gun/Turret Mounts: 0/5</TEXT><TEXT>Armor: 15000</TEXeT><TEXT>Cargo Space: 400</TEXT><TEXT>Max Batteries/Repair Kits: 100/100</TEXT><TEXT>Optimal Weapon Class: NA</TEXT><TEXT >Max. Weapon Class: NA</TEXT><TEXT>Add'l Equipment: NONE</TEXT><PARA></PARA><PARA></PARA><PARA></PARA><PARA></PARA><PARA<></PARA><PARA></PARA><PARA></PARA><PARA></PARA><PARA></PARA><PARA></PARA><PARA></PARA><TRA data="1" mask="1" def="-2"></ TRA><TRA data="0" mask="1" def="-1"></TRA><JUST loc="center"></JUST><JUST loc="left"></JUST><POP></POP></RDL>

The missing xml tags I can sort if needed, but the structure is not the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant