XML with text outside tags... How ?

Hi, I’m writing an app for outputting fcpxml files… which is normal xml but with a different ending.

But, one problem arise…

How do I get text outside tags…

i.e. I want to do this:

Text line 1 continues on line 2.

So how do I get the "Text line 1… etc "part outside tags…

I can not use setAttribute…

fcpxml files is Final cut pro right?
Can you link or post some example from the format of xml ?

https://developer.apple.com/library/mac/documentation/FinalCutProX/Reference/FinalCutProXXMLFormat/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011227-CH1-SW1

XQL is what you need…

[code]// Load XML
Dim xml As New XmlDocument
Try
xml.LoadXml(kTestXml)
Catch e As XmlException
MsgBox("XML error: " + e.Message)
End Try

// Display all the Player names
Dim nodes As XmlNodeList
nodes = xml.XQL("//Player") // Find all Player nodes in XML

// Loop through results and display each name attribute
Dim node As XmlNode
For i As Integer = 0 To nodes.Length-1
node = nodes.Item(i)
MsgBox("Player: " + node.GetAttribute(“name”))
Next[/code]

Check this link XQL Xml element

Hi Loannis, I don’t get it… I’m not loading and looping through… I’m trying to write a file with this inside it… (se first post)

How to make these two lines:

Text line 1
continues on line 2.

for the is use create element
for ref=“ts1” I use setAttribute

but how do I get the last part of the line… (that is the actually text… “Text line 1”+EndOfLine… and the next text)

asset id = your node attribute
“r2” = Your Attribute name
src=“file://Volumes/Media/MyVideo1.mov” = The Value

Here is a save i use for one of my projects

[code] Dim attr As XmlAttribute
Dim xRoot,lvl1,lvl2,lvl3,lvl4,lvl5,lvl6,lvl7 as xmlnode
Dim xName,xValue,tText,xID as string
Dim tname,tvalue,Cell_Name,Cell_Vallue as string
Dim nodes As XmlNodeList
nodes = xDoc.XQL("//farmSiloAmount")
Dim node As XmlNode

nodes = xVehicle.XQL("//onCreateLoadedObject") // Find all farms nodes in XML

Dim sum1,sum2 As Integer

For i As Integer = 0 To nodes.Length-1
node = nodes.Item(i)

if node.AttributeCount >0 then
  For a as integer =0 to node.AttributeCount -1
    attr=node.GetAttributeNode(a)
    
    if attr.name  ="ID" then
      xID = node.GetAttribute("id")
      if xID = wanimals1.Animal1 Then
        node.SetAttribute("manureHeapFillLevel",wanimals1.txtmanureheap.text)
        node.SetAttribute("numAnimals0",wanimals1.txtCows.text)
        node.SetAttribute("liquidManureFillLevel",wanimals1.txtliquid.text)
      end if
      
      for x as integer=0 to node.ChildCount -1
        lvl1= node.Child(x)
        if lvl1.Name ="fillLevelMilk" then
          // xName = lvl1.GetAttribute("fillLevel")
          lvl1.SetAttribute("fillLevel",wanimals1.txtmilk.text)
        end if
      next

      if attr.name  ="id" then
        xID = node.GetAttribute("id")
        if xID = wanimals1.Animal2 Then
          node.SetAttribute("numAnimals0",wanimals1.txtsheeps.text)
        end if
      end if
      
      if attr.name  ="id" then
        xID = node.GetAttribute("id")
        
        if xID = wanimals1.Animal3 Then
          node.SetAttribute("numAnimals0",wanimals1.txtchicken.text)
          wanimals1.txtchicken.Text =xName
        end if
      end if
    end if
  next
end if

next

Dim savefile2 As new FolderItem
savefile2 = SpecialFolder.ApplicationData.Child(“farmingsimulator2015”).Child(selectsavedGame).Child(“vehicles.xml”)

If savefile2 <> Nil Then
xVehicle.SaveXml(savefile2)
End If
[/code]

Thanks but isn’t yours about reading and finding stuff… I want to write a xml file…

What I’m looking for is what someone at steckoverflow refers to as XML tail (text outside tags)

Helge

[quote=256587:@Helge Tjelta]Thanks but isn’t yours about reading and finding stuff… I want to write a xml file…

What I’m looking for is what someone at steckoverflow refers to as XML tail (text outside tags)

Helge[/quote]
I send you a Pm

Is this what you’re looking for, CreateTextNode?

[code]dim doc As new XmlDocument

dim t As XmlNode = doc.AppendChild(doc.CreateElement(“text”))

dim ts As XmlNode = t.AppendChild(doc.CreateElement(“text-style”))

dim txt As XmlNode = ts.AppendChild(doc.CreateTextNode(“Text line 1”+EndOfLine+“continue line 2.”))

TextArea1.Text = doc.ToString[/code]

creates this

<?xml version="1.0" encoding="UTF-8"?><text><text-style>Text line 1 continue line 2.</text-style></text>