.NET XML attribute question

I'm creating a Soap Envelope and I've run into a small problem.  Here is some code :

 Dim se as New SoapEnvelope
 se.loadXml(xmlStr)
 Dim rootElem as XmlElement = se.DocumentElement
 rootElem.SetAttribute("version", "2.0")
 rootElem.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
 rootElem.SetAttribute("xsi:schemaLocation","http://somewhere.com")

 ' More elements added here

 When the Docuement is created and saved it is missing the "xsi" prefix on the schemaLocation attribute.  So instead of  xsi:schemaLocation="blah blah blah" , I am getting schemaLocation="blah blah blah".  I need to have the prefix. 

Is there a way to do this?

Thanks in Advance for suggesions / comments. Big Smile


James
0
kantplayalik
7/19/2006 5:47:28 PM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

1 Replies
1080 Views

Similar Articles

[PageSpeed] 21
Get it on Google Play
Get it on Apple App Store

Use the overloaded SetAttribute() method that accepts a URI as the second parameter:

rootElem.SetAttribute("schemaLocation", "http://www.w3.org/2001/XMLSchema-instance", "http://somewhere.com");

Note that the parameter needs the URI string, not the xmlns prefix that you define.  Because you are including the xmlns:xsi attribute that registers the URI to the "xsi" prefix, all "xsi" nodes will be automatically prefixed with "xsi:".

But, you could do the following:

System.Xml.XmlElement rootElem = doc.DocumentElement;
rootElem.SetAttribute("version", "2.0"
);

string xsi = "http://www.w3.org/2001/XMLSchema-instance";

rootElem.SetAttribute("schemaLocation", xsi, "http://somewhere.com");

Which shows that you wouldn't need to define a xmlns:xsi attribute.  In this case, .NET will create a xmlns prefix that for you (d1p1 in this case):

<xml version="2.0"
d1p1:schemaLocation="
http://somewhere.com"
xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance">


JasonF
A View Inside My Head
0
JasonFollas
7/20/2006 3:02:43 PM
Reply:

Similar Artilces:

XSLT to transform XML into XML in VB.NET
Hello. I need some help with XSLT. We have an XML coming in and I need to transform this XML to a format that we use using XSLT so that future changes in the incoming file are easy to change in the XSLT rather than changing the VB code.This is the sample input file  <MemberReports xsi:schemaLocation="http://developreports/myreport/v1/report.xsd"> <DateCreated>2006-04-15</DateCreated> <MemberReport> <MemberOrganization>MemberOrganization</ReportingOrganization> <Member> <Name> ...

To .NET or not .NET, that is the question
I'm running WinXP pro 32-bit, meaning I've got the version 1-dot-something of .NET that XP came with. I've been looking for various softwares, and more and more often come across .NET version 2 being prerequisite. No urgency for me re. my questions to this group - so far I have just decided to hit the red X on those download pages - but the desire for this newer version of .NET seems to be growing for me. Firstly, according to my (limited) research, newer .NET versions are inclusive of the previous ones, and the current version seems to be 3.5. So if I go for i...

Problems writing to an XML file
I'm brand new to using XML (in fact this is my first project), so bear with me, I may need a little hand-holding. I'm trying to create a page which simply adds data to an existing xml file. Ultimately it will add the data from a form, but to keep things simple, I've been simply using pre-defined values. Originally I was able to get the script to write the xml exactly as I needed, however it would simply overwrite the existing file every time it was accessed. This is unacceptable, as it will be used to add data to one file, sort of like a mini database. So after much pain and gnashi...

HTTP XML POST .NET
Hello,I am using the following code to HTTP post an xml file to third party server. Now I believe I am able to send the file correctly but I need to pass a HTML input field value of type hidden as well with it. If I use a simple HTML interface as shown below I am successful:<form enctype="multipart/form-data" action="https://myurl" method="POST">  <input type="hidden" name="MyFieldName" value="myvalue">  <input type="file" name="Myfile">  <br/>  <input type="submit"></form>I want to simulate the exact thing in my .NET code. I am confuse...

ADO.NET(XML) Datasource missing
Well something has transpired with the ADO.NET(XML) Datasource, it is disappearing off our machines! We’ve been messing around with .NET 2.0 but I’m not sure that this is related.  When we try to validate tables we get “The database DLL ‘crdb_adoplus.dll’ could not be loaded. Just to clarify we are using Crystal Reports 9 Developer Edition, with the cr90dbexwin_en.exe patch to fix issues with the crdb_adoplus.dll   We’ve tried completely uninstalling and reinstalling Crystal with no luck.. Any help would be greatly appreciated....

save XML question and modifing XML question
I am reading a XML file then making changes and then saving it as another name.  I am saving it as another name because I get an "object not found" ?What is the best way to make changes to a XML file? Below is my code.  Also is there another way to add cdata.      Set onode = objXML.createNode("element", "Camp", "")    objXML.documentElement.appendChild(onode)       Set objNewChild = objXML.createElement("xxxxxxx")       objNewChild.Text = "<![CDATA[" + xxxx + "]]"       onod...

XML and .Net
Hi all, Say .... what XML tools work great with .Net? I need to find tools that will work with Creating Web Services in .Net or some tutorials on how to create ... XML Web Services Web Services toggled with SOAP and UDDI thx, Ed Click on "Tutorials" above, and then "Writing a Simple XML Web service" on the left side See if my article helps you http://www.w3coder.com/ws/WSGWBook/WebServGW-01.XML I specifically written this for beginners!Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti...

tool in vs.net to generate xml documentation for vb.net
hello i need a tool in vs.net to generate xml documentation for vb.net thank you for the help and for the time Check out the VB.NET add-in for XML comments.Regards,Alex hello thank you for the support i click the link add-in and the page that has been opened does not have relation what i want Click around in the workspaces area. I think they are redirecting to the 'site update' page no matter what you go to initially. Once you've visited a couple pages, try the link again as it works fine.Regards,Alex...

XMl to XML
Hello,   I retrieved an XML from the dataset which retrieves data from the table in the database. I need to present the data  in a different structure. Is XSLT the way or are there any other options. please let me know. Thanks!! Yes XSLT is a good choice to convert xml file to other forms. You can take a look at XSLT Tutorial.Sincerely,Young Fang...

XML in, XML out
Hi All (and a happy holiday to those that will get a break), I am trying to read in an XML file of addresses. I need to remove all the address data from the file where code =~ /^000/ (there are none in the example data below). I need to reproduce that data 'as is', so I need to honour the tag structure, although the order of the tags doesn't need to be honoured. I have been trying to use XML::Simple and I had a go with XML::Smart but I haven't been able to get the results I want. My best effort is below (with XML::Simple). There are a couple of differences ...

Problem with displaying attributes of xml into nested repeater..How to dispaly attributes of xml nested repeater..(if XML not followed hierarchical structure)
Hello every one I am facing a problem to display attribute of parent node and corresponding child nodes.Suppose I have to display Label attributes of all <ScreenToSupport>. There can be multiple <ScreenToSupport> inside parent node <ScreensToSupport>. In this case I have to display Label 'rediffHomePage' and 'rediffHomePage1' of both <ScreenToSupport> node. There is no issue to diplay these two Label. I done this by taking a repeater control.But problem arrises when I have to display corresponding Label of 'FieldsToSupport/FieldToSupport' of &l...

Newbie Question
I have a new project which has just started. One of the requirements is to generate XML files. Do I have to create schema files? Does anyone have a tutorial or sample code to help me get started. I have some background using XML, but not in .NET. Thx Mark How to create a new xml file with XmlDocument? More examples hereSonu Kapoor [MVP] Feel free to ask me any .NET question | Ajax Data Controls Forum Thanks, this is very helpful. What do I need to do extra to setup the schema for this xml file? Is the schema really necessary as well? Thx Mark You dont need to define any sc...

xml question for xml::twig
Hello, I am praticing below XML file. Based on where I find att id for bayking id 'kingtony' , I wanted to print out the entire element/att(and ID) and any text found from <yahoo> to </yahoo>.(exception of bayqueen_list and its descendatns)... I am having problem just print out one value... can someone take a look please? use strict; use warnings; use XML::Twig; my $xml = <<XML; <foo> <yahoo V="bay"> <bay_id> <value>1</value> <fact>yes</fact> ...

VB.NET: Get the Attribute and Text out from Xml string
Edited by SomeNewKid. Please post code between <code> and </code> tags. Say I have this Xml taken as an example: <Settings> <Connection> <UserID>sa</UserID> <DataSource>Server</DataSource> <InitialCatalog>Database</InitialCatalog> </Connection> </Settings> To get the Xml text is: Dim m_xmld As XmlDocument Dim m_nodelist As XmlNodeList Dim m_node As XmlNode m_xmld = New XmlDocument() m_xmld.Load("Settings.xml") ...

Web resources about - .NET XML attribute question - asp.net.xml-datasource

Attribute - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Template:Attributes of God - Wikipedia, the free encyclopedia
Language: English Română Home Random Template:Attributes of God Part of a series on the Attributes of God Aseity Eternity Graciousness Holiness ...

Six Attributes Of The Perfect Facebook Page Administrator
So, here’s the thing: In many ways, hiring a Facebook page administrator is akin to hiring a poster child for your brand. This trusted manager ...

PANDA: Pose Aligned Networks for Deep Attribute Modeling - Facebook
We propose a method for inferring human attributes (such as gender, hair style, clothes style, expression, action) from images of people under ...

Facebook announces data partnerships to help advertisers target users by offline purchases and attributes ...
... will anonymously match data from consumer loyalty programs with user profiles in order to target ads by offline purchase habits and other attributes. ...

New Study Attributes Rapid Ageing Mainly To Environment Factors
New study explains why some people age faster than others.

Should I use the nofollow attribute on internal links? - YouTube
Regarding "nofollow" on internal links: Does it hurt? Does it help? I read different comments from Matt on this matter over time. What's the ...

Justin Trudeau attributes abortion stance to father's example
Liberal Leader Justin Trudeau says he is following an example set by his famous father when it comes to his position on election candidates and ...

Obama attributes western U.S. wildfires to climate change
... that has burned nearly 400 square miles in the north-central part of Washington state, along with blazes in other Western areas, can be attributed ...

Fifty Shades Of Grey Baby Births: Windsor Hospital Sees Spike In Births, Attribute Book
A significant spike in baby births at a hospital in Windsor, Ontario, has been attributed to the book Fifty Shades of Grey, which has become ...

Resources last updated: 12/21/2015 1:07:41 PM