Jump to content

XML newline


retro-starr
 Share

Recommended Posts

I have an XML file that I need newlines for each entry between two tags. This is an example of what it looks like:

<notes> blah1 blah2</notes>

I don't do anything fancy except drag the file into a new tab in Firefox. In Firefox the output looks like:

blah1 blah2
This is not something I want. I tried using <![CDATA[ ]]>, but that didn't do anything.
Link to comment
Share on other sites

That was my thought at first, but when I opened a file that Firefox does recognize as XML, it did its "XML Thing" (does it have a name?) and sure enough newlines were displayed as a spaces. It's kind of an outliner/interpreter. You can load a file with no whitespace, and it pretty-prints it so you can see the structure.Anyway, Firefox seems to use its own rules for pretty-printing. There is probably no way to change this behavior.

Link to comment
Share on other sites

It doesn't matter how Firefox pretty prints your XML file. The only thing that really matters is if it's parsing it correctly.You can find out by actually trying to put this contents in a place where this will make a difference... say, as the contents of a <pre> element on an HTML page for example. Try it. I'm sure you'll find out the new lines are OK.

Link to comment
Share on other sites

I have a passwd.xml that I made so I take it a step further on the web and do some cool things with it. First of which is figure out how to decrypt the file (using gpg), then display it securely. From there I want to do something fancy like make a UI to add entries to the file and lastly secure it again when done. Maybe I could start a new thread to get help on that?

Link to comment
Share on other sites

The very fact the XML is publically visible (even if in an encrypted state) is probably bad for security on the first place.Assuming you make sure the file is only visible to the server itself, and not to clients, consider encrypting only the different contents (text nodes), not the whole file itself. Why? So that each password can be encrypted and decrypted independantly.You can manipulate XML files with PHP by using DOM which is similar to the one in JavaScript.

Link to comment
Share on other sites

That sounds interesting, how is XML publically visible when still encrypted?
When something is encrypted, it essentially means "gibberish" to the naked eye (and program), and for it to be turned into something readable, it needs to be decrypted by the use of a "key" (sort of a "password" if you will).But when you see gibberish that you know to be encrypted text, nothing stops you from trying out every possible key in an attempt to get something readable. A wrong password will produce more gibberish, so you can rest assure that if the XML is parseable, the key was correct.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...