It is inconvenient to change the XML root for writing a program. Therefore, I wrote a function. the general idea and implementation of this function are as follows: first, I felt that I could filter something using XSLT and then send it back to the client, so I decided to use XSLT and then try to write a root change.
It is inconvenient to change the XML root for writing a program. Therefore, I wrote a function. the general idea and implementation are as follows:
First, I felt that I could filter something using XSLT and send it back to the client. so I decided to use XSLT.
Then try to write an XSL for root replacement, as shown below:
Reference content is as follows:
The general meaning is to parse all nodes and attributes in an XML file. if it is not the root, copy them directly; otherwise, check whether there are child nodes and attributes. For more information, see The SDK documentation of MSXML.
Then write a function so that NEWNODENAME can specify:
This code is implemented in VB. Net. in ASP, you need to pay attention to the use of Set for object values and the title of returned values.
Reference content is as follows:
Public Function ChangeXmlRootNodeName (ByRef oXml As MSXML2.DOMDocument, ByVal name As String) As String
If oXml Is Nothing Then
Return ""
End If
Dim sXslt As String
SXslt =" "& VbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt & vbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt & "<" & name & ">" & vbCrLf"
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt & vbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt &" "& VbCrLf
SXslt = sXslt &" "" & VbCrLf"
SXslt = sXslt &" "" & VbCrLf"
SXslt = sXslt & vbCrLf
SXslt = sXslt &" "& VbCrLf
Dim oXsl As New MSXML2.DOMDocument
OXsl. async = False
OXsl. resolveExternals = False
OXsl. loadXML (sXslt)
Dim sXml As String
SXml = oXml. transformNode (oXsl)
SXml = AddXmlHeader (sXml)
SXsl = Nothing
Return sXml
End Function
Also, of course, you can also implement the XSL file generated by the native XSL, which depends on how you design it.