I want to breakdown an xml document into two. This is basically by accessing the second xml file as external entity. Originally the full document looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>
<par1>Don't forget me this weekend!</par1>
</body>
</note>
this document is saved with file name
mymessage.txt
and i can access the content of par1 tag from powershell as
$xmlFileName = 'E:\mymessage.txt'
[xml]$xmlDoc = Get-Content $xmlFileName
Write-Host $xmlDoc.note.body.par1
This works fine.
What I have tried:
Now i want to split the file into two and I put the body part in separate file called
mymessage_body.txt
and it looks
<?xml version="1.0" encoding="UTF-8"?>
<DOCTYPE body [
<!ELEMENT body (par1)>
<!ELEMENT par1 (#PCDATA)>
]>
<body>
<par1>Don't forget me this weekend!</par1>
</body>
Similarly i put the header part in another file (called
mymessage_header.txt
) and it looks
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note [
<!ELEMENT note ANY>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ENTITY body SYSTEM "mymessage_body.txt">
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
&body;
</note>
Now i tried to access the content of par1 from powershell as shown above it returns nothing. I want to know weather the external entity is properly loaded or not. Would you please forward your suggestion in resolving this? Thanks!