Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Format question

Status
Not open for further replies.

cal555

Programmer
May 5, 2006
71
US
Hi,
this code works greate, to create a an XML Doc. If I no charicters (like =,', or . ) in the create node section below. However, they want the tag to look like this:
<md.securities.tax guid = GHJK426>
How can I make it look like this.

Thank you

Here is my code:

Private Sub CopyValues()

Dim xml_document As DOMDocument
Dim PathGuid_node As IXMLDOMNode
Dim AppPath As String

AppPath = App.Path
If Right$(AppPath, 1) <> "\" Then AppPath = AppPath & "\"

Set xml_document = New DOMDocument

Set PathGuid_node = xml_document.createElement("PathGuid")

PathGuid_node.appendChild xml_document.createTextNode(vbCrLf)

xml_document.appendChild PathGuid_node

CreateNode 4, PathGuid_node, "md.securities.tax guid = GHJK426", GlobalVarNavigationPath
CreateNode 4, PathGuid_node, "md.securities.tax guid = WSLXEE455", GlobalVarNodeGuid
'md.securities.taxonomy guid = SWESE011

Clipboard.Clear

' Sends the XML doc to the clipboard
Clipboard.SetText xml_document.xml

End Sub


Private Sub CreateNode(ByVal indent As Integer, ByVal parent As IXMLDOMNode, ByVal node_name As String, ByVal PathGuid_node As String)

Dim new_node As IXMLDOMNode

parent.appendChild parent.ownerDocument.createTextNode(Space$(indent))

Set new_node = parent.ownerDocument.createElement(node_name)

new_node.Text = PathGuid_node

parent.appendChild new_node

parent.appendChild parent.ownerDocument.createTextNode(vbCrLf)

End Sub
 
This would be legal XML:
Code:
<md.securities.tax guid="GHJK426"/>
Assuming you want an empty element called "md.securities.tax", with a "guid" attribute set to GHJK426. You need to look into how to assign attributes in whatever-language-that-is (VB?).

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
thanks for you help I am extremly new to xml, but was given this project anyway. However, if you could help me understand this a litle beter I would appreciate it. What my code is doing here is making the tag so that it would look like this:

<md.securities.tax guid = GHJK426> </md.securities.tax guid = GHJK426>

Is this not allowed?

Because, if I have one single word in there it works great, it just does not like the characters.
 
You can't have an element called "md.securities.tax guid = GHJK426". Element names can only be made up of letters, numbers, ".", "-" or "_" symbols. So the spaces and the "=" are just no-nos.

However, if "they want the tag to look like this", I suspect they actually mean what I said in my previous post - adding an attribute called [tt]guid[/tt] with a value of [tt]GHJK426[/tt]. Maybe you should go back to "them" for clarification.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thank you, I did go back to them and you are right. For give my lack of knowledge here, As I said I am just started learning this. However, you are right they want it to be a tag but at the same time are teling me it is an attribute. I am going to have to read up on this tonight to see if I can put togther waht they want.
Thank you for you help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top