# Reading XML

**URL:** <https://forum.kirupa.com/t/reading-xml/263250>\
**Category:** Uncategorized\
**Created:** [June 13, 2008, 6:25pm UTC](https://forum.kirupa.com/t/reading-xml/263250 "2008-06-13T18:25:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricmar](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@Ricmar](https://forum.kirupa.com/u/Ricmar)\
**Post date:** [June 13, 2008, 6:25pm UTC](https://forum.kirupa.com/t/reading-xml/263250/1 "2008-06-13T18:25:56Z")

</div>

I have an application im designing thats size or height is determined by how many string characters are present in an external XML content sheet.

However the prob i have found is that if there is a line break in the XML this isnt taken into consideration. The whole line of white space needs to be considered for.

My application will have say 100 character per line, so for everyline break in the xml i need to add an extra 100 characters to my height.

Is there a way to detect line space or can anyone suggest a work around?

---

<div class="post-metadata">

**Author:** ![wvxvw](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@wvxvw](https://forum.kirupa.com/u/wvxvw)\
**Post date:** [June 13, 2008, 8:09pm UTC](https://forum.kirupa.com/t/reading-xml/263250/2 "2008-06-13T20:09:23Z")

</div>

Linebreaks: “\r”, “  
” or both.  
i.e.:

```auto
trace("abcd\rdcba");
trace("abcd\rdcba\refg".replace(/\r/g, "\r-------\r"));

```

---

<div class="post-metadata">

**Author:** ![Ricmar](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@Ricmar](https://forum.kirupa.com/u/Ricmar)\
**Post date:** [June 14, 2008, 10:23am UTC](https://forum.kirupa.com/t/reading-xml/263250/3 "2008-06-14T10:23:19Z")

</div>

I’ll check it out thanks, never seen the replace tags before.

---

<div class="post-metadata">

**Author:** ![Ricmar](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@Ricmar](https://forum.kirupa.com/u/Ricmar)\
**Post date:** [June 14, 2008, 1:27pm UTC](https://forum.kirupa.com/t/reading-xml/263250/4 "2008-06-14T13:27:00Z")

</div>

How would I relate this to the text in the XML?

txtFld.text.replace(/\r/g, “\rmyreplacetext\r”); Doesnt work  
xml.replace(/\r/g, “\rmyreplacetext\r”); Doesnt work

---

<div class="post-metadata">

**Author:** ![wvxvw](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@wvxvw](https://forum.kirupa.com/u/wvxvw)\
**Post date:** [June 14, 2008, 5:55pm UTC](https://forum.kirupa.com/t/reading-xml/263250/5 "2008-06-14T17:55:42Z")

</div>

```auto
var randomStringWithLinebreaks:String = 'abcd\rabcdef\rabcdefghijklm\rabcdefghijkl\rabcdefghijklmopqrst';
trace('-------------');
trace('* before *\r');
trace(randomStringWithLinebreaks);
trace('-------------');
var arr:Array = randomStringWithLinebreaks.split('\r');
var i:int = 0;
while(i < arr.length) {
	var charsToAdd:int = 11 - arr*.length;
	var tempString:String;
	if (charsToAdd > 0)	{
		arr* = arr* + new Array(charsToAdd).join('*');
	} else {
		tempString = arr*.slice(10, arr*.length);
		arr* = arr*.slice(0, 10);
		arr.splice(i + 1, 0, tempString);
	}
	i++;
}
randomStringWithLinebreaks = arr.join('\r');
trace('* after *\r');
trace(randomStringWithLinebreaks);
trace('-------------');

```

Does it have to be something like this?  
.replace was used to show what happens if you remove/insert linebreak characters (notice, XML.replace() and String.replace() are two different functions).

---

<div class="post-metadata">

**Author:** ![Ricmar](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@Ricmar](https://forum.kirupa.com/u/Ricmar)\
**Post date:** [June 14, 2008, 6:21pm UTC](https://forum.kirupa.com/t/reading-xml/263250/6 "2008-06-14T18:21:48Z")

</div>

Wow thats a handfull.

At first glance it does look like it will do the trick, ill check it out and see where it takes me.  
Thanks for the effort
