Android Question Problems recording new XML element in XML file

Valeriy Lakhtin

Member
Licensed User
Hi frends! When I edit XML elements inside XML file, the file is saved well. When I create a new multi-level XML element and add them into the XML file, the contents of the new element is written incorrectly. Chars ">" and "<" inside the new XML element replaced text "&lt;" and "&gt;". See the example below. This element is name "otvet" has internal elements ...
B4X:
<otvet IMEI="2544778" Phon="+77782532177">name&gt;Cargo trans group ghjgghkj&lt;/name&gt;&lt;time&gt;1469011029517&lt;/time&gt;&lt;www&gt;www.informbyuro.dggfhh&lt;/www&gt;&lt;coment&gt;Обращайтесь к разработчикам www.informbyuro.kz. Здесь могла бы быть ваша реклама или краткое описание услуги, но не более 30 букв&lt;/coment&gt;&lt;phone num="77122754374" /&gt;&lt;phone num="+7702342255" /&gt;</otvet>
Code which gives the following result
B4X:
                    strQuery="//object [@ID='" & ID & "']"
                    xomNull=xomRootOtvet
                    Log(strQuery)
                    xomNs=xomNull.Query(strQuery)
                    xomObj=xomNs.GetNode(0)
                  
                    xomNew.Initialize("otvet")
                    atrIMEI.Initialize("IMEI",smsIMEI)
                    xomNew.AddAttribute(atrIMEI)
                    atrPhon.Initialize("Phon",smsPhon)
                    xomNew.AddAttribute(atrPhon)

                    xomName.Initialize("name")
                    xomName.AppendChild(smsName)
                    xomNew.AppendChild(xomName.ToXML)
                    DateTime.DateFormat="dd/MM/yyyy HH:mm:ss"      
                    strTime=DateTime.Now
                    xomTime.Initialize("time")
                    xomTime.AppendChild(strTime)
                    xomNew.AppendChild(xomTime.ToXML)
                    If smsWWW<>"" Then
                        xomWWW.Initialize("www")
                        xomWWW.AppendChild(smsWWW)
                        xomNew.AppendChild(xomWWW.ToXML)
                    End If  
                    If smsComent<>"" Then
                        xomComent.Initialize("coment")
                        xomComent.AppendChild(smsComent)
                        xomNew.AppendChild(xomComent.ToXML)
                    End If  
                    If smsPhon1<>"" Then
                        xomPhon.Initialize("phone")
                        atrNum.Initialize("num",smsPhon1)
                        xomPhon.AddAttribute(atrNum)
                        xomNew.AppendChild(xomPhon.ToXML)
                    End If  
                    If smsPhon2<>"" Then
                        xomPhon.Initialize("phone")
                        atrNum.Initialize("num",smsPhon2)
                        xomPhon.AddAttribute(atrNum)
                        xomNew.AppendChild(xomPhon.ToXML)
                    End If  
                    If smsPhon3<>"" Then
                        xomPhon.Initialize("phone")
                        atrNum.Initialize("num",smsPhon3)
                        xomPhon.AddAttribute(atrNum)
                        xomNew.AppendChild(xomPhon.ToXML)
                    End If  
                    Log(xomNew.ToXML)
                    xomObj.AppendChild(xomNew.ToXML)
 
Top