Jump to content
  • Advertisement
Sign in to follow this  
gamechampionx

Xml.XmlDocument problem

This topic is 4754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Dim tempNode As Xml.XmlNode
                tempNode = myDoc.CreateNode(XmlNodeType.Element, "copySite", "")
                Dim tempProperty As Xml.XmlAttribute
                tempProperty = myDoc.CreateAttribute("siteidtocopy")
                tempProperty.Value = """" & oldBaseSiteId & originalBaseCountIndex.ToString & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("newsiteid")
                tempProperty.Value = """" & newBaseSiteId & i.ToString & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("title")
                tempProperty.Value = """" & baseTitle & i.ToString & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("description")
                tempProperty.Value = """" & baseDescription & i.ToString & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("shortdesc")
                tempProperty.Value = """" & baseShortDesc & i.ToString & """"""
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("iconurl")
                tempProperty.Value = """" & iconUrl & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("infourl")
                tempProperty.Value = """" & infoUrl & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("joinable")
                tempProperty.Value = """" & joinable & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("joinerrole")
                tempProperty.Value = """" & joinerRole & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("published")
                tempProperty.Value = """" & published & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("publicview")
                tempProperty.Value = """" & publicView & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("skin")
                tempProperty.Value = """" & skin & """"
                tempNode.Attributes.Append(tempProperty)
                tempProperty = myDoc.CreateAttribute("type")
                tempProperty.Value = """" & type & """"
                tempNode.Attributes.Append(tempProperty)
                MsgBox(tempNode.Attributes.Count)
                MsgBox("count: " & tempNode.Attributes.Count)
                MsgBox("about to append child")
                myDoc.AppendChild(tempNode)
                MsgBox("appended child")
myDoc is an Xml.XmlDocument that works fine and has just read in some things. All of the variables such as oldBaseSiteIt are fine. The program gets to "about to append child", and the myDog.AppendChild statement fails. Why does this happen? This is in VB.net btw.

Share this post


Link to post
Share on other sites
Advertisement
e.GetType.ToString = System.EventArgs .

Do you know what that type specifies or what could be the problem? It may be something stupid as I've never used this Xml class before, or VS.net, but I am relatively good at programming.

Share this post


Link to post
Share on other sites
I don't think your property values need to be wrapped in double quotes. It will do that for you. If you really wanted double quotes as part of your property values you need you change your """" to """ ( " is the escape sequence for " in XML)

Share this post


Link to post
Share on other sites
Thanks, I fixed the quotes and solved the problem. I had to add the tag to the document's inner document object instead of the main document itself.

Now, the program works, but the tags generated only show up properly in some programs. Internet Explorer will show the line breaks properly, while WordPad just puts it all on one line. What's the deal with this? Can I fix it?

Share this post


Link to post
Share on other sites
The spaces between elements can be ignored by xml processors unless explictly told not too. Wordpad probably just doesn't care about how xml is formatted and displays it as if it's a text file.

Share this post


Link to post
Share on other sites
Yeah I guess. XML editors put in the appropriate spaces generally, and line breaks, which is pretty cool. I wish there was a way to force the document to be saved in a nicely formatted way.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!