Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1015
  • Last Modified:

offline xml unencoder

I'm after a link to an offline XML unencoder. Basically a static HTML page that will let me paste in the contents of an XML tag, and will unencode all the &amp, &quot, &gt etc.

I am currently using XML Marker and I like it because its lightweight and simple (I primarily paste in existing XML to inspect it), but it does not seem to have this kind of functionality.


FYI the bigger picture is that I copy a URL string out of the browser, unencode it with a static HTML URL decoder (http://meyerweb.com/eric/tools/dencoder/), then paste that into an XML editor for inspection. I need the XML tag contents to also be unencoded though. Maybe there is a tool that does it all in one go.


Oh, and of course preferably free!
0
nmcdermaid
Asked:
nmcdermaid
  • 5
  • 3
1 Solution
 
abelCommented:
I think I can create what you want within a reasonable time, if I don't find one online, but it seems that this is probably already you want: http://www.opinionatedgeek.com/dotnet/tools/HtmlEncode/Decode.aspx

Just to make sure I understand you correctly, do you mean that:

<!-- this code -->
<myxml>&lt;b&gt;bold text incorrectly inside encoded tags&lt;/b&gt;</myxml>
 
<data>
&lt;html&gt;
  &lt;body&gt;
    &lt;p&gt;
      &quot;some text&quot;
    &lt;/p&gt;
   &lt;/body&gt;
&lt;/html&gt;
</data>
 
 
<!-- should be translated into this code? -->
<myxml><b>bold text incorrectly inside encoded tags</b></myxml>
 
<data>
<html>
  <body>
    <p>
      "some text"
    </p>
   </body>
</html>
</data>

Open in new window

0
 
nmcdermaidAuthor Commented:
Yes the example you have given is what I'm after - basically rather than having to search/replace all those codes, I'd like to paste it in and do the lot.
The link you posted doesn't seem to do that though (plus its online - I don't want to have to install an aspx page)
Basically a static HTML page with some javascript to do the search/replace on the pasted string would be fantastic.
Something that would do both (Button 1 - de-encode URL string. Button 2 - de econde XML string) would be absolutely fantastic!
Its really just a search/replace if I understand it correctly.
Even if you did a small static web page with some javascript with a limited subset of tokens, I could extend to the rest.
I just can't seem to find something like it on the web.
PS thank you for responding.
0
 
abelCommented:
> The link you posted doesn't seem to do that though

I used that link to create the example above. Why doesn't it work for you, am I missing some detail about what you want en/decoded?

I'll try to build a little page for you.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
abelCommented:
Ok, I created a very simple HTMLEncoder/Decoder which I put online for future reference. The trick that is exposed is simple but efficient: just set the data as innerHTML of an element (hidden of course) and read it back in as nodeValue. Works flawlessly on IE7 and FF3 (not tested further, but technique is well known).

In the code below tempDiv is any temporary div with at least one character content and hidden (display:none). The "encoded" and "decoded" should be textareas. For more information, see the working version online.

-- Abel --

// the basic idea:
 
function HTMLdecode(){
    var tempDiv = document.getElementById("tempDiv");
    tempDiv.innerHTML = document.getElementById("encoded").value;            
    document.getElementById("decoded").value = tempDiv.childNodes[0].nodeValue;
}
function HTMLencode(){
    var tempDiv = document.getElementById("tempDiv");
    tempDiv.childNodes[0].nodeValue = document.getElementById("decoded").value;
    document.getElementById("encoded").value = tempDiv.innerHTML;
}

Open in new window

0
 
nmcdermaidAuthor Commented:
Thanks abel. My apologies for taking so long to get back to you. That certainly works for the example data that I indicated, but when I paste in my particualr XML escaped string, does not unescape as expected. It is entirely likely that I misled you above on the type of data to unencode.
I have pasted my XML encoded string below. If that is pasted into the HTML page it returns run
Possibly it does not match the type of data that I indicated earlier - sorry!
As an overview I am:
1. Capturing the parameter part of a URL string which is passed to a web app
2. Passing that through a URL decode HTML app which basically uses unescape(encoded.replace(/\+/g,  " ")); to decode the URL
3. That gives me the posted string below which is valid XML and pastes into XML Marker OK, but has lots of nasty escaped XML such as &apos; in it.
If I can get the string below to decode then can stick it all together and make one page that makes decoding easier for me.
My apologies for dragging this on, I really do appreciate your efforts.
 

<authoredDrillRequest><param name="action">run</param><param name="target">/content/folder[@name=&apos;Packages&apos;]/package[@name=&apos;Maintenance&apos;]/folder[@name=&apos;Labour Utilisation&apos;]/folder[@name=&apos;Management Reporting&apos;]/report[@name=&apos;KPI 9 - Man Hours Allocated&apos;]</param><param name="format">HTMLFragment</param><param name="locale">en-au</param><param name="prompt">false</param><param name="sourceContext">&lt;bus:parameters xsi:type=&quot;SOAP-ENC:Array&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; SOAP-ENC:arrayType=&quot;bus:baseParameter[2]&quot; xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; xmlns:bus=&quot;http://developer.cognos.com/schemas/bibus/3/&quot;&gt;
    &lt;item xsi:type=&quot;bus:parameter&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
      &lt;bus:name xsi:type=&quot;xs:string&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:bus=&quot;http://developer.cognos.com/schemas/bibus/3/&quot;&gt;pWorkArea&lt;/bus:name&gt;
      &lt;bus:type xsi:type=&quot;bus:parameterDataTypeEnum&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:bus=&quot;http://developer.cognos.com/schemas/bibus/3/&quot;&gt;memberUniqueName&lt;/bus:type&gt;
    &lt;/item&gt;
    &lt;item xsi:type=&quot;bus:parameter&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
      &lt;bus:name xsi:type=&quot;xs:string&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:bus=&quot;http://developer.cognos.com/schemas/bibus/3/&quot;&gt;pDates&lt;/bus:name&gt;
      &lt;bus:type xsi:type=&quot;bus:parameterDataTypeEnum&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:bus=&quot;http://developer.cognos.com/schemas/bibus/3/&quot;&gt;memberUniqueName&lt;/bus:type&gt;
    &lt;/item&gt;
  &lt;/bus:parameters&gt;</param><param name="objectPaths">&lt;bus:objectPaths xsi:type=&quot;SOAP-ENC:Array&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; SOAP-ENC:arrayType=&quot;bus:searchPathSingleObject[4]&quot; xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; xmlns:bus=&quot;http://developer.cognos.com/schemas/bibus/3/&quot;&gt;
    &lt;item xsi:type=&quot;bus:searchPathSingleObject&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;i62E0D313C7E34D0BA55A952247589B14&lt;/item&gt;
    &lt;item xsi:type=&quot;bus:searchPathSingleObject&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;iF8A53A4BA46C462F9987E8848AA7459B/model[last()]&lt;/item&gt;
    &lt;item xsi:type=&quot;bus:searchPathSingleObject&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;/content/folder[@name=&amp;apos;Packages&amp;apos;]/package[@name=&amp;apos;Maintenance&amp;apos;]/model[@name=&amp;apos;model&amp;apos;]&lt;/item&gt;
    &lt;item xsi:type=&quot;bus:searchPathSingleObject&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;/content/folder[@name=&amp;apos;Packages&amp;apos;]/package[@name=&amp;apos;Maintenance&amp;apos;]/model[last()]&lt;/item&gt;
  &lt;/bus:objectPaths&gt;</param><drillParameters><param name="p_pWorkArea">&lt;selectChoices&gt;&lt;selectOption useValue=&quot;[(cube) MN_KPI_LabourUtilisation].[All Work Areas].[All Work Areas].[Site]-&amp;gt;:[PC].[@MEMBER].[Callide]&quot; displayValue=&quot;Callide&quot;/&gt;&lt;/selectChoices&gt;</param><param name="p_pDates">&lt;selectChoices&gt;&lt;selectOption useValue=&quot;[(cube) MN_KPI_LabourUtilisation].[All Dates].[Relative Time]-&amp;gt;:[PC].[@MEMBER].[Last 2 Months]&quot; displayValue=&quot;Last 2 Months&quot;/&gt;&lt;/selectChoices&gt;</param></drillParameters><param name="executionParameters">H4sIAAAAAAAAAO1UTU-CQBA9669oejBqQpePW8VGRA5EigTwI2mI2ZYJbNzuNjtbPv692wKlIHrSm73sZua9N29mJ22GKboJVTQGDQqtVcwFuiZ4a8*1TlxCprAALhNQTiRnQqI5YoLRHGKKJGQGShrE3hJXyAricrl0lg1HqhmpV6s18ub3RjmtwgRqKiIwLGSuXidwa4*eWoNKp992W0rR9U5vFy1Et4Udk0ZJk1w9uxAQkZwyMTNWCimaSY1z*YM2XyhPIahPbO-8LP*aTENcMvMVXUDPmllSmFQJv0IXtTLVbS95oBqaZAc6pC0yqR*a-sF5nNvoGp9BbW-8tHVkccJhUCaVGBsrTEQ8RbY4aiOUkgMVtqdVum2jQB5LTBkmnK5Pz6FHUVt1y5dCz3EjtMUfy6T4zSiDyygN4cry***Pg*57j4YyVc*acYZUMykmTtDi3MoGjuY*BG7CpqExi2FSuZjpGzcYtE3mzu-4952huR24mmxsmfqlcZJsnvtXI8WzFbtygPjNzWkpoP*b442ML7Su-3RnXqX6sLJ546lA5uAXlmOT3-9cvU8qo6NLbQUAAA__</param></authoredDrillRequest>

Open in new window

0
 
abelCommented:
The problem is mixed correct XML and escaped XML. To have any encoding / decoding working, you'll have to loop through the correct XML (i.e., the params) and use the decoder on each part. For instance, if I remove the first two params, and I add it to the decoder on the link, I get:

<!-- output text -->
 
<!-- first param -->
/content/folder[@name='Packages']/package[@name='Maintenance']/folder[@name='Labour Utilisation']/folder[@name='Management Reporting']/report[@name='KPI 9 - Man Hours Allocated']
 
<!-- second param -->
<bus:parameters xsi:type="SOAP-ENC:Array" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENC:arrayType="bus:baseParameter[2]" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">
    <item xsi:type="bus:parameter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <bus:name xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">pWorkArea</bus:name>
      <bus:type xsi:type="bus:parameterDataTypeEnum" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">memberUniqueName</bus:type>
    </item>
    <item xsi:type="bus:parameter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <bus:name xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">pDates</bus:name>
      <bus:type xsi:type="bus:parameterDataTypeEnum" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">memberUniqueName</bus:type>
    </item>
  </bus:parameters>

Open in new window

0
 
abelCommented:
So, in other words, where you are using your unescape(encoded.replace(/\+/g,  " "));  (in step 2) to decode the string, you should place my function and you should be fine.
0
 
nmcdermaidAuthor Commented:
OK, thanks I'll give it a shot.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now