• 0

How do I output a backslash \ character in XML?


Question

4 answers to this question

Recommended Posts

  • 0

If it is an attribute, then it will just work, but I'm assuming you're trying to put it as text between tags:

<someXml>\a path\to\a\file</someXml>

In that case, you need to use a CDATA section.

<someXml>
<![CDATA[
	  \a path\to\a\file
   ]]>
</someXml>

  • 0
  $phinX said:

Ive found a couple of articles saying use: \ but that still errors.

LoL, just noticed that didnt come out... or it did... that backslash is actually a '&' followed by hex number, which obviously works for HTML but not XML.

  weenur said:

If it is an attribute, then it will just work, but I'm assuming you're trying to put it as text between tags:

Yeah im trying to up it between tags as text. Is CDATA the only way? There is no escape character sequence?

  • 0
  $phinX said:

LoL, just noticed that didnt come out... or it did... that backslash is actually a '&' followed by hex number, which obviously works for HTML but not XML.

Yeah im trying to up it between tags as text. Is CDATA the only way? There is no escape character sequence?

Wasn't really thinking, but you should be able to use the ASCII code equivalent.

& #92;

Gah! This is actually rendering the \ . lol It's ampersand, pound, ninety-two, and semicolon.

You may want to try using HttpServerUtility.HtmlEncode if you want to encode on the fly before you insert into a node's value.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • That explains my recent issues with classic Outlook. I can see the FORMS2 folder has resolved the issue on my system.
    • Brave 1.79.126 by Razvan Serea Brave Browser is a lightning-fast, secure web browser that stands out from the competition with its focus on privacy, security, and speed. With features like HTTPS Everywhere and built-in tracker blocking, Brave keeps your online activities safe from prying eyes. Brave is one of the safest browsers on the market today. It blocks third-party data storage. It protects from browser fingerprinting. And it does all this by default. Speed - Brave is built on Chromium, the same technology that powers Google Chrome, and is optimized for speed, providing a fast and responsive browsing experience. Brave Browser also features Brave Rewards, a system that rewards users with Basic Attention Tokens (BAT) for viewing opt-in ads. This innovative system provides an alternative revenue model for content creators and a way to support the Brave community. Brave 1.79.126 changelog: Fixed crash when clicking on shields panel in certain cases. Fixed crash on navigation when a Google sign-in request has been triggered. (#46769) Fixed crash when Leo generates empty list when clicking on “Suggest questions” while using BYOM (Bring Your Own Model). (#46843) Fixed issue importing from Trezor wallet when Trezor Connect is outdated. (#46660) Upgraded Chromium to 137.0.7151.119. (#46911) Download: Brave Browser 64-bit | 1.2 MB (Freeware) Download: Brave Browser 32-bit View: Brave Homepage | Offline Installers | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • LeafView 3.6.5 by Razvan Serea LeafView is a fast, open-source image viewer built with Electron. It offers a sleek, minimal UI for fast and efficient image browsing. Supporting various formats, LeafView ensures a smooth viewing experience with essential features like zoom, rotation, and slideshow mode. Designed for simplicity and performance, it utilizes hardware acceleration for smooth rendering and supports touch gestures for seamless navigation. LeafView key features: Lightweight & Open-Source – Minimal resource usage with a clean, efficient design Electron-Based – Cross-platform compatibility with modern UI Multiple Image Format Support – Opens JPG, PNG, GIF, BMP, and more Smooth Rendering – Hardware acceleration for fast performance Essential Image Controls – Zoom, rotate, and slideshow mode Touch Gesture Support – Seamless navigation on compatible devices Minimal UI – Focused on simplicity and ease of use LeafView 3.6.5 changelog: Update electron to v36.5.0 Download: LeafView 3.6.5 | Portable | ~100.0 MB (Open Source) View: LeafView Website | Other operating systems | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Which is why I continue to use Open Shell for my start menu. your best course of action is to install a third-party Start menu
  • Recent Achievements

    • First Post
      Fuzz_c earned a badge
      First Post
    • First Post
      TIGOSS earned a badge
      First Post
    • Week One Done
      slackerzz earned a badge
      Week One Done
    • Week One Done
      vivetool earned a badge
      Week One Done
    • Reacting Well
      pnajbar earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      700
    2. 2
      ATLien_0
      280
    3. 3
      Michael Scrip
      208
    4. 4
      +FloatingFatMan
      196
    5. 5
      Steven P.
      130
  • Tell a friend

    Love Neowin? Tell a friend!