How to use XmlNode() as result from webservice in VB.NET?
A webservice just returns XmlNode():
Dim nodes() As XmlNode = CType(result.handler, XmlNode())
First of all, how can this result be viewed as plain xml (in visual studio)?
And then, how to use this result and navigate / select concrete items from it?
xml vb.net xmlnode
add a comment |
A webservice just returns XmlNode():
Dim nodes() As XmlNode = CType(result.handler, XmlNode())
First of all, how can this result be viewed as plain xml (in visual studio)?
And then, how to use this result and navigate / select concrete items from it?
xml vb.net xmlnode
1
1. how can this result be viewed as plain xml (in visual studio)?: Do you mean like while debbuging? If you just stop the mouse pointer over the variable, you can view its contents! 2. how to use this result and navigate / select concrete items from it?: Do you have a class that represents the contents of this result? If so, you can deserialize the XmlNode into your object, that's the easiest way, I think, otherwise you can just use the Xml library to navigate through it. Please give more information about what you really want.
– Pedro Gaspar
Dec 28 '18 at 1:01
1. I don't mean the debugger in this context. It drives me crazy when viewing the nested objects ;) I would like to view the the whole xml structure like a dom document. Looking for something like $nodesArray->toXmlString() 2. There is no target class at them moment. have to use Xml library, but what to use when not having an XmlDocument but only an XmlNodes()?
– JKB
Dec 28 '18 at 1:48
Since is is an array you have to convert one item in the array at a time. So I usually use something like this string xml = string.Join("n", nodes.Select(x => x.ToString()));
– jdweng
Dec 28 '18 at 11:14
add a comment |
A webservice just returns XmlNode():
Dim nodes() As XmlNode = CType(result.handler, XmlNode())
First of all, how can this result be viewed as plain xml (in visual studio)?
And then, how to use this result and navigate / select concrete items from it?
xml vb.net xmlnode
A webservice just returns XmlNode():
Dim nodes() As XmlNode = CType(result.handler, XmlNode())
First of all, how can this result be viewed as plain xml (in visual studio)?
And then, how to use this result and navigate / select concrete items from it?
xml vb.net xmlnode
xml vb.net xmlnode
asked Dec 28 '18 at 0:48
JKB
12010
12010
1
1. how can this result be viewed as plain xml (in visual studio)?: Do you mean like while debbuging? If you just stop the mouse pointer over the variable, you can view its contents! 2. how to use this result and navigate / select concrete items from it?: Do you have a class that represents the contents of this result? If so, you can deserialize the XmlNode into your object, that's the easiest way, I think, otherwise you can just use the Xml library to navigate through it. Please give more information about what you really want.
– Pedro Gaspar
Dec 28 '18 at 1:01
1. I don't mean the debugger in this context. It drives me crazy when viewing the nested objects ;) I would like to view the the whole xml structure like a dom document. Looking for something like $nodesArray->toXmlString() 2. There is no target class at them moment. have to use Xml library, but what to use when not having an XmlDocument but only an XmlNodes()?
– JKB
Dec 28 '18 at 1:48
Since is is an array you have to convert one item in the array at a time. So I usually use something like this string xml = string.Join("n", nodes.Select(x => x.ToString()));
– jdweng
Dec 28 '18 at 11:14
add a comment |
1
1. how can this result be viewed as plain xml (in visual studio)?: Do you mean like while debbuging? If you just stop the mouse pointer over the variable, you can view its contents! 2. how to use this result and navigate / select concrete items from it?: Do you have a class that represents the contents of this result? If so, you can deserialize the XmlNode into your object, that's the easiest way, I think, otherwise you can just use the Xml library to navigate through it. Please give more information about what you really want.
– Pedro Gaspar
Dec 28 '18 at 1:01
1. I don't mean the debugger in this context. It drives me crazy when viewing the nested objects ;) I would like to view the the whole xml structure like a dom document. Looking for something like $nodesArray->toXmlString() 2. There is no target class at them moment. have to use Xml library, but what to use when not having an XmlDocument but only an XmlNodes()?
– JKB
Dec 28 '18 at 1:48
Since is is an array you have to convert one item in the array at a time. So I usually use something like this string xml = string.Join("n", nodes.Select(x => x.ToString()));
– jdweng
Dec 28 '18 at 11:14
1
1
1. how can this result be viewed as plain xml (in visual studio)?: Do you mean like while debbuging? If you just stop the mouse pointer over the variable, you can view its contents! 2. how to use this result and navigate / select concrete items from it?: Do you have a class that represents the contents of this result? If so, you can deserialize the XmlNode into your object, that's the easiest way, I think, otherwise you can just use the Xml library to navigate through it. Please give more information about what you really want.
– Pedro Gaspar
Dec 28 '18 at 1:01
1. how can this result be viewed as plain xml (in visual studio)?: Do you mean like while debbuging? If you just stop the mouse pointer over the variable, you can view its contents! 2. how to use this result and navigate / select concrete items from it?: Do you have a class that represents the contents of this result? If so, you can deserialize the XmlNode into your object, that's the easiest way, I think, otherwise you can just use the Xml library to navigate through it. Please give more information about what you really want.
– Pedro Gaspar
Dec 28 '18 at 1:01
1. I don't mean the debugger in this context. It drives me crazy when viewing the nested objects ;) I would like to view the the whole xml structure like a dom document. Looking for something like $nodesArray->toXmlString() 2. There is no target class at them moment. have to use Xml library, but what to use when not having an XmlDocument but only an XmlNodes()?
– JKB
Dec 28 '18 at 1:48
1. I don't mean the debugger in this context. It drives me crazy when viewing the nested objects ;) I would like to view the the whole xml structure like a dom document. Looking for something like $nodesArray->toXmlString() 2. There is no target class at them moment. have to use Xml library, but what to use when not having an XmlDocument but only an XmlNodes()?
– JKB
Dec 28 '18 at 1:48
Since is is an array you have to convert one item in the array at a time. So I usually use something like this string xml = string.Join("n", nodes.Select(x => x.ToString()));
– jdweng
Dec 28 '18 at 11:14
Since is is an array you have to convert one item in the array at a time. So I usually use something like this string xml = string.Join("n", nodes.Select(x => x.ToString()));
– jdweng
Dec 28 '18 at 11:14
add a comment |
1 Answer
1
active
oldest
votes
First of all, how can this result be viewed as plain xml (in visual studio)?
You can use XmlNode.WriteTo(XmlWriter)
method, using a XmlWriter
object created for writing to a StringBuilder
object (documentation), for example:
Imports System.Text
Imports System.Xml
'[...]
Public Function NodesToString(nodes() As XmlNode) As String
Dim sb As New StringBuilder()
Dim settings As New XmlWriterSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.Indent = True
Dim writer = XmlWriter.Create(sb, settings)
For Each node In nodes
node.WriteTo(writer)
Next
writer.Close()
Return sb.ToString()
End Function
After that all the contents of your nodes should be on your StringBuilder
object, and a simple sb.ToString()
would show it all to you.
And then, how to use this result and navigate / select concrete items from it?
XmlNode
is the base class for a lot of elements in the System.Xml
library, even XmlDocument
and XmlElement
classes, so a lot of the XML "navigation capability" is there.
As stated by the documentation:
This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document.
XmlNode
is the base class in the .NET implementation of the DOM. It supports XPath selections and provides editing capabilities. TheXmlDocument
class extendsXmlNode
and represents an XML document. You can useXmlDocument
to load and save XML data. It also includes methods for node creation. See XML Document Object Model (DOM) for more information.
You can use those properties or methods to navigate through your XML nodes, for example:
XmlNode.FirstChild
property
XmlNode.NextSibling
property
XmlNode.CreateNavigator()
method
XmlNode.SelectNodes()
method (using XPath expression)
XmlNode.SelectSingleNode()
method (using XPath expression)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952482%2fhow-to-use-xmlnode-as-result-from-webservice-in-vb-net%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First of all, how can this result be viewed as plain xml (in visual studio)?
You can use XmlNode.WriteTo(XmlWriter)
method, using a XmlWriter
object created for writing to a StringBuilder
object (documentation), for example:
Imports System.Text
Imports System.Xml
'[...]
Public Function NodesToString(nodes() As XmlNode) As String
Dim sb As New StringBuilder()
Dim settings As New XmlWriterSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.Indent = True
Dim writer = XmlWriter.Create(sb, settings)
For Each node In nodes
node.WriteTo(writer)
Next
writer.Close()
Return sb.ToString()
End Function
After that all the contents of your nodes should be on your StringBuilder
object, and a simple sb.ToString()
would show it all to you.
And then, how to use this result and navigate / select concrete items from it?
XmlNode
is the base class for a lot of elements in the System.Xml
library, even XmlDocument
and XmlElement
classes, so a lot of the XML "navigation capability" is there.
As stated by the documentation:
This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document.
XmlNode
is the base class in the .NET implementation of the DOM. It supports XPath selections and provides editing capabilities. TheXmlDocument
class extendsXmlNode
and represents an XML document. You can useXmlDocument
to load and save XML data. It also includes methods for node creation. See XML Document Object Model (DOM) for more information.
You can use those properties or methods to navigate through your XML nodes, for example:
XmlNode.FirstChild
property
XmlNode.NextSibling
property
XmlNode.CreateNavigator()
method
XmlNode.SelectNodes()
method (using XPath expression)
XmlNode.SelectSingleNode()
method (using XPath expression)
add a comment |
First of all, how can this result be viewed as plain xml (in visual studio)?
You can use XmlNode.WriteTo(XmlWriter)
method, using a XmlWriter
object created for writing to a StringBuilder
object (documentation), for example:
Imports System.Text
Imports System.Xml
'[...]
Public Function NodesToString(nodes() As XmlNode) As String
Dim sb As New StringBuilder()
Dim settings As New XmlWriterSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.Indent = True
Dim writer = XmlWriter.Create(sb, settings)
For Each node In nodes
node.WriteTo(writer)
Next
writer.Close()
Return sb.ToString()
End Function
After that all the contents of your nodes should be on your StringBuilder
object, and a simple sb.ToString()
would show it all to you.
And then, how to use this result and navigate / select concrete items from it?
XmlNode
is the base class for a lot of elements in the System.Xml
library, even XmlDocument
and XmlElement
classes, so a lot of the XML "navigation capability" is there.
As stated by the documentation:
This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document.
XmlNode
is the base class in the .NET implementation of the DOM. It supports XPath selections and provides editing capabilities. TheXmlDocument
class extendsXmlNode
and represents an XML document. You can useXmlDocument
to load and save XML data. It also includes methods for node creation. See XML Document Object Model (DOM) for more information.
You can use those properties or methods to navigate through your XML nodes, for example:
XmlNode.FirstChild
property
XmlNode.NextSibling
property
XmlNode.CreateNavigator()
method
XmlNode.SelectNodes()
method (using XPath expression)
XmlNode.SelectSingleNode()
method (using XPath expression)
add a comment |
First of all, how can this result be viewed as plain xml (in visual studio)?
You can use XmlNode.WriteTo(XmlWriter)
method, using a XmlWriter
object created for writing to a StringBuilder
object (documentation), for example:
Imports System.Text
Imports System.Xml
'[...]
Public Function NodesToString(nodes() As XmlNode) As String
Dim sb As New StringBuilder()
Dim settings As New XmlWriterSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.Indent = True
Dim writer = XmlWriter.Create(sb, settings)
For Each node In nodes
node.WriteTo(writer)
Next
writer.Close()
Return sb.ToString()
End Function
After that all the contents of your nodes should be on your StringBuilder
object, and a simple sb.ToString()
would show it all to you.
And then, how to use this result and navigate / select concrete items from it?
XmlNode
is the base class for a lot of elements in the System.Xml
library, even XmlDocument
and XmlElement
classes, so a lot of the XML "navigation capability" is there.
As stated by the documentation:
This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document.
XmlNode
is the base class in the .NET implementation of the DOM. It supports XPath selections and provides editing capabilities. TheXmlDocument
class extendsXmlNode
and represents an XML document. You can useXmlDocument
to load and save XML data. It also includes methods for node creation. See XML Document Object Model (DOM) for more information.
You can use those properties or methods to navigate through your XML nodes, for example:
XmlNode.FirstChild
property
XmlNode.NextSibling
property
XmlNode.CreateNavigator()
method
XmlNode.SelectNodes()
method (using XPath expression)
XmlNode.SelectSingleNode()
method (using XPath expression)
First of all, how can this result be viewed as plain xml (in visual studio)?
You can use XmlNode.WriteTo(XmlWriter)
method, using a XmlWriter
object created for writing to a StringBuilder
object (documentation), for example:
Imports System.Text
Imports System.Xml
'[...]
Public Function NodesToString(nodes() As XmlNode) As String
Dim sb As New StringBuilder()
Dim settings As New XmlWriterSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
settings.Indent = True
Dim writer = XmlWriter.Create(sb, settings)
For Each node In nodes
node.WriteTo(writer)
Next
writer.Close()
Return sb.ToString()
End Function
After that all the contents of your nodes should be on your StringBuilder
object, and a simple sb.ToString()
would show it all to you.
And then, how to use this result and navigate / select concrete items from it?
XmlNode
is the base class for a lot of elements in the System.Xml
library, even XmlDocument
and XmlElement
classes, so a lot of the XML "navigation capability" is there.
As stated by the documentation:
This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document.
XmlNode
is the base class in the .NET implementation of the DOM. It supports XPath selections and provides editing capabilities. TheXmlDocument
class extendsXmlNode
and represents an XML document. You can useXmlDocument
to load and save XML data. It also includes methods for node creation. See XML Document Object Model (DOM) for more information.
You can use those properties or methods to navigate through your XML nodes, for example:
XmlNode.FirstChild
property
XmlNode.NextSibling
property
XmlNode.CreateNavigator()
method
XmlNode.SelectNodes()
method (using XPath expression)
XmlNode.SelectSingleNode()
method (using XPath expression)
answered Dec 28 '18 at 15:25
Pedro Gaspar
539321
539321
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952482%2fhow-to-use-xmlnode-as-result-from-webservice-in-vb-net%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
1. how can this result be viewed as plain xml (in visual studio)?: Do you mean like while debbuging? If you just stop the mouse pointer over the variable, you can view its contents! 2. how to use this result and navigate / select concrete items from it?: Do you have a class that represents the contents of this result? If so, you can deserialize the XmlNode into your object, that's the easiest way, I think, otherwise you can just use the Xml library to navigate through it. Please give more information about what you really want.
– Pedro Gaspar
Dec 28 '18 at 1:01
1. I don't mean the debugger in this context. It drives me crazy when viewing the nested objects ;) I would like to view the the whole xml structure like a dom document. Looking for something like $nodesArray->toXmlString() 2. There is no target class at them moment. have to use Xml library, but what to use when not having an XmlDocument but only an XmlNodes()?
– JKB
Dec 28 '18 at 1:48
Since is is an array you have to convert one item in the array at a time. So I usually use something like this string xml = string.Join("n", nodes.Select(x => x.ToString()));
– jdweng
Dec 28 '18 at 11:14