Using Visual Studio 2008 Professional trying to read an xml file and assign
the value (the file content) to a variable so that I can pass the variable
as an XML document to another function.
The code below tells me that I cannot convert a type string to a
system.xml.xmldocument.
Dim xmldoc As New Xml.XmlDocument
Dim rdr As New StreamReader("C:\Meeting\NewMeeting.xml", Encoding.UTF8)
xmldoc = rdr.ReadToEnd ' Value of Type String cannot be converted to
System.xml.xmlDocument
Any help will be appriciated!
Rafael
Dim myXMLDocument As New XmlDocument
Dim myXMLNodeList As XmlNodeList
Dim myXMLNode As XmlNode
myXMLDocument.Load("C:\test.xml")
myXMLNodeList = myXMLDocument.SelectNodes("/ParentNodeName/childNodeName")
For Each myXMLNode In myXMLNodeList
dim strTest as string = myXMLNode.Item("UserCredentials").InnerText
next
You can either loop through all the nodes or remove the For Each in which
you specify the record and item like
myXMLNOde(0).item(0).innertext
Hope that helps!
I thought that was the extent of my problem but what's really at work here
is going from XDocument (LINQ format) to xml.xmlDocument (standard Visual
Studio xml DOM?).
I really like the new LINQ Queries to mange xml becuase being such a newbie,
I can understand it much better.
That said, I have not figured out a way to pull out the "outerXml" from an
xml doc using the new LINQ language. On the function below, the
GetBytes(xmldoc.OuterXml) part requires a regular DOM xml doc as the new
LINQ format does not support that particular feature. So if there's a way
to get something similar to an "OuterXml" from a linq xml doc, than I'm
golden.
Thanks,
public XmlDocument PostXmlMessageRequest(XmlDocument xmldoc)
{
// Upon entering, xmldoc = messageRequest
// Upon exit, xmlReply = messageReply;
ASCIIEncoding encoder = new ASCIIEncoding();
XmlDocument xmlReply = null ;
// Post the <messageRequest> element to the conference center;
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(postingUrl);
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse myResp = null;
try
{
// Write the XML message to the request stream and
// send it to the conference center
byte[] byteArray = encoder.GetBytes(xmldoc.OuterXml);
myReq.ContentLength = byteArray.Length;
Stream reqStream = myReq.GetRequestStream();
reqStream.Write(byteArray, 0, byteArray.Length);
reqStream.Close();
// Get the response from the conference center
myResp = (HttpWebResponse)myReq.GetResponse();
Stream respStream = myResp.GetResponseStream();
if (myResp.ContentType == "application/xml")
{
xmlReply = new XmlDocument();
xmlReply.Load(respStream);
}
}
catch (Exception e)
{
// Log the error or implement other error handling routines
Console.WriteLine("Error: {0}\nStack trace: {1}",
e.Message, e.StackTrace);
}
finally
{
if (myResp != null)
myResp.Close();
}
return xmlReply;
}
"Micah Bell" <mb...@gmail.com> wrote in message
news:05b50f7ccae54719...@newspe.com...
http://msdn2.microsoft.com/en-us/library/bb894286.aspx
<PlaceWareConfCenter authUser="apiuser" authPassword="Pa$$w0rd">
<CreateMeetingRequest
maxUsers="100"
name="ShipParty"
title="Come to celebrate">
<OptionList>
<TimeOption name="startTime" value="2007-10-27T14:00:00Z"/>
<TimeOption name="endTime" value="2007-10-27T18:00:00Z"/>
<StringOption name="timeZone" value="America/Los_Angeles"/>
<EnumerationOption name="meetingType" value="OneTime" >
<String>OneTime</String>
<String>MeetNow</String>
<String>Recurring</String>
</EnumerationOption>
</OptionList>
<FieldList>
<Name>name</Name>
<Name>meetingType</Name>
<Name>mid</Name>
<Name>presenterPassword</Name>
<Name>audiencePassword</Name>
</FieldList>
</CreateMeetingRequest>
</PlaceWareConfCenter>
Thanks,
Rafael
"Micah Bell" <mb...@gmail.com> wrote in message
news:05b50f7ccae54719...@newspe.com...