473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Read XML document from Web Service

Hello-

I am looking for the best way to run different Xpath expressions from a web
service, and return the appropriate XML data. The data source that the web
service queries is an XML file, that is not very large (less than 2 MB).

I can retrieve the entire XML file, but I would like to have separate
functions in the web service to pick out certain elements of the file and
basically filter the XML data. There are different methods for invoking
this action (XMLreader, XMLSelectNode, etc...). Can anyone provide some
guidance for the easiest method? Any examples would be most appreciated.

Thanks
Mar 16 '06 #1
1 1862
Here's something I wrote last week to work with XML messages
manually... I give it the xml and what I'm looking for. I expose this
to VB clients so they can access any property they want to in the web
service response message.

using System;
using System.Xml;

namespace XmlSupport
{
public static class XmlSearch
{
private static string FindLeaf(XmlNode node, string leaf) {
foreach (XmlNode child in node.ChildNodes) {
if (child.NodeType == XmlNodeType.Element) {
string returnValue = FindLeaf(child, leaf);
if (!String.IsNullOrEmpty(returnValue)) {
return returnValue;
}

}
else {
if (node.Name == leaf) {
if
(!String.IsNullOrEmpty(node.ChildNodes[0].Value)) {
return node.ChildNodes[0].Value;
}
else {
return String.Empty;
}
}
}
}

return String.Empty;
}

public static string SearchTree(string xml, string leaf) {
XmlDocument xmlDocument = new XmlDocument( );
xmlDocument.LoadXml(xml);

foreach (XmlNode node in xmlDocument.ChildNodes) {
string returnValue = FindLeaf(node, leaf);
if (!String.IsNullOrEmpty(returnValue)) {
return returnValue;
}
}

return String.Empty;
}
}
}

David Betz
WinFX Harmonics Blog
http://www.davidbetz.net/winfx/

Mar 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Daniel Frey | last post by:
Hello, I've got a problem. Either I have missed the most important point or it really does not work: I want to use the document function with an absolut path on WindowsXP Professional and...
7
by: SQLScott | last post by:
I have a Web Service in which I am trying to pass an XMLDocument as a parameter to one of the methods. I would like to use the XMLTextReader to read the XML but I am getting the following error: ...
1
by: Kevin | last post by:
I have the following Xml document (see end of post) with many external resources that need to get resolved. When I "view" the Xml document in Internet Explorer (Windows XP SP2, IE 6.0.2900) all of...
1
by: R.A. | last post by:
Hi, I have an web service method that accept an xml document and returns a different xml document. Based on the input xml I fill a dataset with information from a database. If the dataset has...
3
by: Yolande | last post by:
Hi there, In the document I fount on web sit http://download.microsoft.com/download/1/b/b/1bb6e11f-8e8c-46bf-a2d7-9a16976d4526/NETConnectedLogoTechnicalSpec020904.doc, it says that “To be .NET...
0
by: lozd | last post by:
Hi, I've been building a webservice in dotnet to match a provided WSDL document to allow interoperability with a third party developer's system. As a start point I used the wsdl.exe command line...
4
by: ianyian | last post by:
hi experts, im doing some staff bween th the aspx + MS Word.chellcheck, and and which running on my ypc is no problem ( windows xp , activation by ASPNET ), buts someshow when i try to deploy to...
5
by: GH | last post by:
Can someone point me to an example of a VB.Net client that reads an XML Document from a web service? I have a web service that successfully creates an XML document, saves it on the server and...
1
by: Ronald S. Cook | last post by:
Can I not read an XML document from within a Web Service? When I call .Read() it doesn't then do what it should. It doesn't give me an error, though. It may be because I'm using the AJAX...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.