473,785 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to parse XML out of an XMLHTTP40 object

I'm connecting to an exchange public folder and pulling out contacts via XML.
I can use the .responseText to view the text string. The response from
Exchange in this string is formatted in XML. I'm trying to figure out what I
could use to parse the info out of the response because I need to write the
values to SQL.

Here's the code:

try
{
MSXML2.XMLHTTP4 0 oXMLHttp = new MSXML2.XMLHTTP4 0();

//TODO: To list items, uncomment "const bool bListItems = false;"
// const bool bListFolders = true;
const bool bListItems = false;
String sUrl;
//TODO: Replace ExchServer with your Exchange server and UserAlias with
your user alias.
sUrl= "http://cartman/public";
oXMLHttp.open(" SEARCH", sUrl, false, "n-sv\\kris", "28273De,") ;

//TODO: Use this query to list items.
String sQuery;
sQuery = "<?xml version='1.0'?> " +
"<g:searchreque st xmlns:g='DAV:'> " +
"<g:sql>SEL ECT \"DAV:displayna me\", \"DAV:creationd ate\",
\"urn:schemas:c ontacts:telepho neNumber\" " +
"FROM SCOPE('SHALLOW TRAVERSAL OF \"" + sUrl + "\"')" +
" WHERE \"DAV:isfolder\ " = " + bListItems.ToSt ring()+
"</g:sql>" +
"</g:searchrequest >";
/*
//TODO: Use this query to list folders.
String sQuery;
sQuery = "<?xml version='1.0'?> " +
"<g:searchreque st xmlns:g='DAV:'> " +
"<g:sql>SEL ECT \"DAV:displayna me\" " +
"FROM SCOPE('SHALLOW TRAVERSAL OF \"" + sUrl + "\"')" +
" WHERE \"DAV:isfolder\ " = " + bListFolders.To String() +
"</g:sql>" +
"</g:searchrequest >";
*/

oXMLHttp.setReq uestHeader("Con tent-Type", "text/xml");
oXMLHttp.setReq uestHeader("Tra nslate", "f");
oXMLHttp.setReq uestHeader("Con tent-Length", "" + sQuery.Length);
Console.WriteLi ne(sQuery);
oXMLHttp.send(s Query);

// Need to create a stream to pass to the XmlTextReader
// stream = new StringReader(oX MLHttp.response XML.ToString()) ;

// xtr = new XmlTextReader(s tream);

// xtr.WhitespaceH andling = WhitespaceHandl ing.All;

txtResults.Text = oXMLHttp.respon seText;
// if(xtr.Read())
// txtResults.Text = xtr.NodeType.To String() +
xtr.Name.ToStri ng() + xtr.Value.ToStr ing();

// probably take and return the status number to a literal
// 207 seems to indicate good possibly describe the others
Console.WriteLi ne(oXMLHttp.sta tus);
Console.WriteLi ne(oXMLHttp.sta tusText);
Console.WriteLi ne(oXMLHttp.res ponseText);

}
catch (Exception ex)
{
Console.WriteLi ne("{0} Exception caught.", ex);
}
Nov 16 '05 #1
1 2893
There is a good example on searching Exchange folders on
http://msdn.microsoft.com/library/en...ching_folders_
http.asp

Take a look, and see if you still need to ask about anything.

Regards,
John Wadie

Nov 16 '05 #2

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

Similar topics

24
3176
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and their types. I would like to somehow store a reference to parsing operations in this array (such as Int32.Parse, Double.Parse, SqlMoney.Parse, etc), so I can invoke the appropriate one without writing a long switch.
2
3755
by: Samuel | last post by:
Hello, I am trying to convert a local time into UTC ISO8601, then parse it back into local time. I tried the following: ---------------------- #!/usr/bin/python import time import datetime import xml.utils.iso8601
3
3247
by: Bob Rundle | last post by:
I would like to get something like this to work... Type t = FindMyType(); // might be int, float, double, etc string s = "1233"; object v = t.Parse(s); This doesn't work of couse, Parse is not a member of Type. I have to think that this is possible. Is it?
3
3342
by: c0uch | last post by:
the first and third methods are in a usercontrol object. txtValue is a TextBox the float.parse in the if statement on line 3 always works fine. the second float.parse in the third method is quirky: if the program just runs it will always break on that line, vc# 2005 beta2 shows txtValue.Text as null at this point. However, if I put a breakpoint on the first float.parse (on line 3), and then step out until i reach the second float.parse,...
3
6824
by: Kevin Kenny | last post by:
Dear All, I have a date time validation method thus: public static bool IsDate(string date, System.IFormatProvider provider) { try { DateTime.Parse(date, provider) return true; } catch (System.FormatException) return false;
3
3084
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New Binding("Text", Me.Ds1, "Items.BidAmt") txtBidAmt.DataBindings.Add(oBidAmt) Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
8
10415
by: Douglas Crockford | last post by:
There is a new version of JSON.parse in JavaScript. It is vastly faster and smaller than the previous version. It uses a single call to eval to do the conversion, guarded by a single regexp test to assure that it is safe. JSON.parse = function (text) { return (/^(\s|]|"(\\|)*"|-?\d+(\.\d*)?(?\d+)?|true|false|null)+$/.test(text)) && eval('(' + text + ')'); };
3
3151
by: MMiGG | last post by:
Hi Our project need parse JAVA serialized object string in C, has any library? Thanx
5
5145
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. Could someone help me with the customization? Thanks. String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.