有没有一个工具可以自动用动态生成的 GUID 替换一堆 GUID?
我不是开发人员。
我需要破解一个 XML 文件来复制数百个资源,每个资源都分配有一个 GUID。有没有一种方法可以解析整个文件,用动态生成的 GUID 替换标签中找到的每个 GUID?
基本上 - 每个 UniqueID 标签(但不是 ContentUniqueID 标签)都需要一个新的 GUID。
<root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<Name>[redacted]</Name>
<UniqueId>7a136c33-3ea8-4f99-8f99-bbe411972203</UniqueId>
<Enabled>true</Enabled>
<Behavior>EmptyOnly</Behavior>
<Subscriptions />
<ScheduledFormatTemplates>
<ScheduledFormatTemplate>
<Name>[redacted]</Name>
<UniqueId>1cfaba3e-bfd5-4d2f-a1df-14020ad2f7da</UniqueId>
<ContentUniqueId>67c58741-fe1b-4c15-8dc0-8b4c01f6f18f</ContentUniqueId>
<ScheduledContents>
<ScheduledContent xsi:type="SFTR">
<Name>[redacted]</Name>
<UniqueId>b4a60646-b62b-43e7-b2a2-7d37875ab33f</UniqueId>
<ContentUniqueId>ba634a97-9faf-4bfa-a9b4-d8a2475b82e6</ContentUniqueId>
<ScheduledContents>
<ScheduledContent>
<Name>[redacted]</Name>
<UniqueId>6f8e6e6c-1f94-4caa-8730-6859448138eb</UniqueId>
<ContentUniqueId>938b0a24-4043-4a16-bc2d-25dbdb21a659</ContentUniqueId>
</ScheduledContent>
</ScheduledContents>
</ScheduledContent>
</ScheduledContents>
</ScheduledFormatTemplate>
</ScheduledFormatTemplates>
</root>
I'm not a developer.
I need to hack an XML file to duplicate hundreds of resources that are each assigned a GUID. Is there a way to parse the entire file, replacing each GUID found in a tag with a dynamically generated one?
Basically - every UniqueID tag (but not the ContentUniqueID tags) needs a new GUID.
<root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<Name>[redacted]</Name>
<UniqueId>7a136c33-3ea8-4f99-8f99-bbe411972203</UniqueId>
<Enabled>true</Enabled>
<Behavior>EmptyOnly</Behavior>
<Subscriptions />
<ScheduledFormatTemplates>
<ScheduledFormatTemplate>
<Name>[redacted]</Name>
<UniqueId>1cfaba3e-bfd5-4d2f-a1df-14020ad2f7da</UniqueId>
<ContentUniqueId>67c58741-fe1b-4c15-8dc0-8b4c01f6f18f</ContentUniqueId>
<ScheduledContents>
<ScheduledContent xsi:type="SFTR">
<Name>[redacted]</Name>
<UniqueId>b4a60646-b62b-43e7-b2a2-7d37875ab33f</UniqueId>
<ContentUniqueId>ba634a97-9faf-4bfa-a9b4-d8a2475b82e6</ContentUniqueId>
<ScheduledContents>
<ScheduledContent>
<Name>[redacted]</Name>
<UniqueId>6f8e6e6c-1f94-4caa-8730-6859448138eb</UniqueId>
<ContentUniqueId>938b0a24-4043-4a16-bc2d-25dbdb21a659</ContentUniqueId>
</ScheduledContent>
</ScheduledContents>
</ScheduledContent>
</ScheduledContents>
</ScheduledFormatTemplate>
</ScheduledFormatTemplates>
</root>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道有这样的工具,但开发人员应该能够生成一个 powershell 脚本或 perl 脚本,在 10-15 分钟内完成此操作。
如果您发布 XML 文件的示例,我敢打赌有人甚至可能会发布工作代码。如果您将问题表述为挑战,就会得到更多人的回应。根据 XML 文件的复杂性,脚本可能只有 10 行。
如果还有其他要求,例如 - 如果您希望从特定范围中选择新的 GUID - 这仍然是可能且简单的,但您需要说明所有这些要求。
I don't know of a tool like that, but a developer ought to be able to produce a powershell script, or a perl script, that does this in a matter of 10-15 minutes.
If you post the sample of the XML file, I'll bet someone might even post working code. If you phrase your Q as a challenge, you'll get more people to respond. Depending on the complexity of the XML file, it might be as few as 10 lines of script.
If there are other requirements, like - if you want the new GUIDs to all be selected from a particular range - that will still be possible and straightforward, but you'll need to state all those requirements.
此处有一个基于网络的工具可以执行此操作
There is a web-based tool that does this here