473,772 Members | 3,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to determine assigned namespace prefix

Hello,

I'm receiving a response XML doc and need to know which letter was assigned
by the server to a namespace.

For example, here's a doc that I got returned to me. I need to extract the
"subject", so I need to know that "e" was assigned because I'm using the
..Net "GetElementsByT agName" method: (GetElementsByT agName("e:subje ct")):

<?xml version="1.0"?>
<a:multistatu s xmlns:b="urn:uu id:c2f41010-65b3-11d1-a29f-188741245e/"
xmlns:e="urn:sc hemas:httpmail: " xmlns:f="urn:sc hemas:mailheade r:"
xmlns:c="xml:" xmlns:d="urn:sc hemas:calendar: " xmlns:a="DAV:">
<a:response>
<a:href>http://mail.mydomain.c om/exchdav/milop/Installations/APPT20066991416 33.eml</a:href>
<a:propstat>
<a:status>HTT P/1.1 200 OK</a:status>
<a:prop>
<d:location>HOM E</d:location>
<e:subject>SUBJ ECT</e:subject>
<d:contact>MILO P CONTACT</d:contact>
<d:dtstart b:dt="dateTime. tz">2006-06-09T08:00:00.000 Z</d:dtstart>
<d:dtend b:dt="dateTime. tz">2006-06-09T08:00:00.000 Z</d:dtend>
<d:instancety pe b:dt="int">0</d:instancetype>
<f:message-id>2006-06-09-09.13.55.732000 </f:message-id>
</a:prop>
</a:propstat>
<a:propstat>
<a:status>HTT P/1.1 404 Resource Not Found</a:status>
<a:prop>
<d:busystatus/>
<f:content-location/>
</a:prop>
</a:propstat>
</a:response>
</a:multistatus>
Is there a quick XPath expression or something in System.XML that will aid
in this?

Thanks in advance,

Mike
Jun 9 '06 #1
3 1779
Nevermind, I found it: GetPrefixOfName space.

Couldn't be more simple.

"MikeL" <mi***@slomins. com> wrote in message
news:uI******** ******@TK2MSFTN GP03.phx.gbl...
Hello,

I'm receiving a response XML doc and need to know which letter was
assigned by the server to a namespace.

For example, here's a doc that I got returned to me. I need to extract the
"subject", so I need to know that "e" was assigned because I'm using the
.Net "GetElementsByT agName" method: (GetElementsByT agName("e:subje ct")):

<?xml version="1.0"?>
<a:multistatu s xmlns:b="urn:uu id:c2f41010-65b3-11d1-a29f-188741245e/"
xmlns:e="urn:sc hemas:httpmail: " xmlns:f="urn:sc hemas:mailheade r:"
xmlns:c="xml:" xmlns:d="urn:sc hemas:calendar: " xmlns:a="DAV:">
<a:response>

<a:href>http://mail.mydomain.c om/exchdav/milop/Installations/APPT20066991416 33.eml</a:href>
<a:propstat>
<a:status>HTT P/1.1 200 OK</a:status>
<a:prop>
<d:location>HOM E</d:location>
<e:subject>SUBJ ECT</e:subject>
<d:contact>MILO P CONTACT</d:contact>
<d:dtstart b:dt="dateTime. tz">2006-06-09T08:00:00.000 Z</d:dtstart>
<d:dtend b:dt="dateTime. tz">2006-06-09T08:00:00.000 Z</d:dtend>
<d:instancety pe b:dt="int">0</d:instancetype>
<f:message-id>2006-06-09-09.13.55.732000 </f:message-id>
</a:prop>
</a:propstat>
<a:propstat>
<a:status>HTT P/1.1 404 Resource Not Found</a:status>
<a:prop>
<d:busystatus/>
<f:content-location/>
</a:prop>
</a:propstat>
</a:response>
</a:multistatus>
Is there a quick XPath expression or something in System.XML that will aid
in this?

Thanks in advance,

Mike

Jun 9 '06 #2


MikeL wrote:
I'm receiving a response XML doc and need to know which letter was assigned
by the server to a namespace.


For your example you could load the XML file into an XmlDocument
instance and then call
xmlDocumentInst ance.DocumentEl ement.GetPrefix OfNamespace("ur n:schemas:httpm ail:")
which would yield the string "e".
If all namespace declarations are on the document element/root element
node simply using GetPrefixOfName space on that DocumentElement should
solve the problem in general.
In theory of course a descendant node of the document element could
redefine the prefix but that was not the case in your example.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 9 '06 #3
Thanks Martin.

"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:OL******** ******@TK2MSFTN GP04.phx.gbl...


MikeL wrote:
I'm receiving a response XML doc and need to know which letter was
assigned by the server to a namespace.


For your example you could load the XML file into an XmlDocument instance
and then call
xmlDocumentInst ance.DocumentEl ement.GetPrefix OfNamespace("ur n:schemas:httpm ail:")
which would yield the string "e".
If all namespace declarations are on the document element/root element
node simply using GetPrefixOfName space on that DocumentElement should
solve the problem in general.
In theory of course a descendant node of the document element could
redefine the prefix but that was not the case in your example.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Jun 9 '06 #4

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

Similar topics

25
3097
by: kj | last post by:
Consider the following XML document: <?xml version='1.0' encoding='UTF-8'?> <bar:foo xmlns:bar='someuri'> <baz/> </bar:foo> What namespace does baz belong to? What is this namespace bound to/associated with? My understanding was that baz above belongs to some "default default namespace", but I have not been able to
3
10043
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0" xmlns:ns1="abc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" media-type="text/xml" standalone="yes" version="1.0"/> <xsl:template match="/">
4
12168
by: AP | last post by:
Hi, I have a class that I wish to serialize to XML, part of which looks like this: public class TitleNotification { public string NoNameSpaceSchemaLocation = http://www.pdr.com\nhttps://extw3c.pdr.com/prism/b2b/schemas/TitleNotification.xsd;
4
20503
by: Krishna Tulasi via .NET 247 | last post by:
Hi, I am having trouble with creation of XML programmatically using .NET. Specifically Im trying to create an element which looks like below and insert into an existing xml doc: <Worksheet ss:Name="TKCSheet1"> </Worksheet> The existing xml doc is: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?>
5
5737
by: pneumoconi | last post by:
I've read a lot of posts on this subject each with a slightly different issue and from what I gather my code is fine. But its not. I'm trying to pull out the SQL query from a SQL report document which looks something like this: <?xml version="1.0" encoding="utf-8"?> <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">...
2
11407
by: Manoj G | last post by:
Hello, I believe there is no way to remove the default namespace declaration (For eg <DataSet xmlns="something">.... ) on an XmlNode object directly through DOM. So, what is the best way to remove it 1) XSLT templates? 2) Copy all the contents into a new node and leave out the namespace? Use this node node in lieu of the old one?
5
2408
by: David Thielen | last post by:
Hi; I set up my xml as follows: XmlDocument xml = new XmlDocument(); xml.Load(File.Open("data.xml", FileMode.Open, FileAccess.Read)); XmlNamespaceManager context = new XmlNamespaceManager(xml.NameTable); context.AddNamespace("", "http://www.test.org"); context.AddNamespace("sns", "http://www.test.org/sub"); XmlNode node = xml.SelectSingleNode("/root", context);
18
7739
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr); System.out.println(xp.evaluate(new InputSource(new FileInputStream("a.xml"))));
2
21639
by: scottpet | last post by:
Hi, I want to add a namespace prefix to the root node of an object I am serializing to XML. I have been reading though this article: http://msdn2.microsoft.com/en-gb/library/system.xml.serialization.xmlnamespacedeclarationsattribute.aspx I get namespace prefixes in the document, but not on the root node. Specifically, the serializer does not work as described in the last
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9912
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...
1
7460
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
6715
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
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.