Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You problem resolves around this line....</p> <pre><code> resultParent = resultParent + "&amp;#xA;" </code></pre> <p>Now, you are probably trying to output your XML like this:</p> <pre><code>&lt;PARENT&gt;George Aaron&amp;#xA; Susan Lee Aaron&amp;#xA; Richard Elliot Aaron&amp;#xA;&lt;/PARENT&gt; </code></pre> <p>However, this escaped <code>&amp;#xA;</code> entity is only relevant if the document has yet to be parsed. If it were a text document, that gets subsequent read and parsed into an XML document, then the entities would be handled as expected. But you are working with an XML document that has already been parsed. Therefore, when you do <code>resultParent = resultParent + "&amp;#xA;"</code> it is actually going to insert a string of five characters into an existing text node, and because <code>&amp;</code> is a special character, it gets escaped.</p> <p>Now, what you can simply do is this...</p> <pre><code> resultParent = resultParent + chr(10) </code></pre> <p>But ultimately this will prove fruitless because HTML doesn't recognise line-break characters, so you would have to write your XSLT to replace the line break with a <code>&lt;br /&gt;</code> element.</p> <p>If you wanted to do this in your VB code though, you could create new <code>br</code> elements yourself, and insert them</p> <pre><code>For Each par As System.Xml.XmlNode In parentNodes currentParentValue = par.InnerText par.InnerText = String.Empty Dim parArray As String() = currentParentValue.Split(";") For Each Parent As String In parArray If Parent.Length &gt; 0 Then Dim person As XmlText = objOutput.CreateTextNode(Parent) par.AppendChild(person) par.AppendChild(objOutput.CreateElement("br")) End If Next Next </code></pre> <p>So, this takes the <strong>PARENT</strong> node, clears it down, then adds a text node, and new <strong>br</strong> element for each parent. The output would then be like so, which would be much easier to output as HTML using XSLT</p> <pre><code>&lt;PARENT&gt;George Aaron&lt;br /&gt;Susan Lee Aaron&lt;br /&gt;Richard Elliot Aaron&lt;br /&gt;&lt;/PARENT&gt; </code></pre> <p>(It shouldn't be too hard to add the <strong>br</strong> after every second parent if required).</p> <p>However, if may not necessarily be a good idea to put "presentational" information in a XML file. Suppose you later had to transform the XML into a different format? An alternate approach would be separate each parent into their own element.</p> <pre><code>For Each par As System.Xml.XmlNode In parentNodes currentParentValue = par.InnerText par.InnerText = String.Empty Dim parArray As String() = currentParentValue.Split(";") For Each Parent As String In parArray If Parent.Length &gt; 0 Then Dim person As XmlElement = objOutput.CreateElement("PERSON") person.InnerText = Parent.Trim() par.AppendChild(person) End If Next Next </code></pre> <p>This would output something like this..</p> <pre><code>&lt;PARENT&gt; &lt;PERSON&gt;George Aaron&lt;/PERSON&gt; &lt;PERSON&gt;Susan Lee Aaron&lt;/PERSON&gt; &lt;PERSON&gt;Richard Elliot Aaron&lt;/PERSON&gt; &lt;PERSON&gt;Albert Smith&lt;/PERSON&gt; &lt;/PARENT&gt; </code></pre> <p>Displaying this as HTML would also be straight-forward </p> <p>Hint: To display in groups of two, your XSLT may look something like this....</p> <pre><code>&lt;xsl:for-each select="PERSON[postion() mod 2 = 1]"&gt; &lt;xsl:value-of select="."&gt;; &lt;xsl:value-of select="following-sibling::PERSON[1]" /&gt; &lt;br /&gt; &lt;/xsl:for-each&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload