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

Home Posts Topics Members FAQ

SetAttribute xlink:href

Hello all,

I am having difficulty figuring out how to create an XmlElement and giving
it an attribute that requires a namespace. Here is what I have so far which
throws an exception because you can't have a : in an attribute name???

XmlElement eOnlineResource = m_context.Creat eElement("Onlin eResource");

eOnlineResource .SetAttribute(" xlink:href", "http://www.w3c.org/1999/xlink",
sldUrl);

Any help is appreciated.
Aug 22 '06 #1
4 4764
See: http://www.dotnet247.com/247referenc...43/216508.aspx

-------------------------------------------------------------------------------------------------------------
Dim xdoc As New XmlDocument
Dim eOnlineResource As XmlElement

xdoc.LoadXml("< root xmlns='DefaultN SDickster'
xmlns:xlink='ht tp://www.w3c.org/1999/xlink'></root>")

eOnlineResource =
xdoc.CreateElem ent("eOnLineRes ource","Default NSDickster")

eOnlineResource .SetAttribute(" href",
"http://www.w3c.org/1999/xlink", "theValue")

xdoc.FirstChild .AppendChild(eO nlineResource)

-------------------------------------------------------------------------------------------------------------

The prefix will be in the XML.

Dickster

Aug 22 '06 #2
Thanks but that still doesn't work. I think it has to do with the fact that
I am operating on a node and not a document. Here is my code:

XmlNode sldUrlNode =
layerNode.Selec tSingleNode("St yleList/Style/SLD/OnlineResource" );

if (sldUrlNode == null)
{
// we need to create the SLD Node if it does not exist
XmlElement eStyleList =
m_context.Creat eElement("Style List");

XmlElement eStyle = m_context.Creat eElement("Style ");
eStyle.SetAttri bute("current", "1");

eStyleList.Appe ndChild(eStyle) ;

XmlElement eSLD = m_context.Creat eElement("SLD") ;

XmlElement eName = m_context.Creat eElement("Name" );
eName.InnerText = layerName;

eSLD.AppendChil d(eName);

XmlElement eOnlineResource =
m_context.Creat eElement("Onlin eResource", "xlink");

eOnlineResource .SetAttribute(" href",
"http://www.w3.org/1999/xlink", sldUrl);

eSLD.AppendChil d(eOnlineResour ce);

eStyle.AppendCh ild(eSLD);

layerNode.Appen dChild(eStyleLi st);

}
else
{

sldUrlNode.Attr ibutes[0].Value = sldUrl;
}
}
}
"dickster" wrote:
See: http://www.dotnet247.com/247referenc...43/216508.aspx

-------------------------------------------------------------------------------------------------------------
Dim xdoc As New XmlDocument
Dim eOnlineResource As XmlElement

xdoc.LoadXml("< root xmlns='DefaultN SDickster'
xmlns:xlink='ht tp://www.w3c.org/1999/xlink'></root>")

eOnlineResource =
xdoc.CreateElem ent("eOnLineRes ource","Default NSDickster")

eOnlineResource .SetAttribute(" href",
"http://www.w3c.org/1999/xlink", "theValue")

xdoc.FirstChild .AppendChild(eO nlineResource)

-------------------------------------------------------------------------------------------------------------

The prefix will be in the XML.

Dickster

Aug 22 '06 #3


jvanulden wrote:
I am having difficulty figuring out how to create an XmlElement and giving
it an attribute that requires a namespace. Here is what I have so far which
throws an exception because you can't have a : in an attribute name???

XmlElement eOnlineResource = m_context.Creat eElement("Onlin eResource");

eOnlineResource .SetAttribute(" xlink:href", "http://www.w3c.org/1999/xlink",
sldUrl);
This should help:

XmlDocument xmlDocument = new XmlDocument();
XmlElement eOnlineResource =
xmlDocument.Cre ateElement("Onl ineResource");
XmlAttribute xlinkHref = xmlDocument.Cre ateAttribute("x link",
"href", "http://www.w3.org/1999/xlink");
xlinkHref.Value = "http://example.com/example";
eOnlineResource .SetAttributeNo de(xlinkHref);

For the attribute value you obviously want your sldUrl then instead of
the example.com URL the example shows.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 22 '06 #4
Thanks Martin, that worked!

"Martin Honnen" wrote:
>

jvanulden wrote:
I am having difficulty figuring out how to create an XmlElement and giving
it an attribute that requires a namespace. Here is what I have so far which
throws an exception because you can't have a : in an attribute name???

XmlElement eOnlineResource = m_context.Creat eElement("Onlin eResource");

eOnlineResource .SetAttribute(" xlink:href", "http://www.w3c.org/1999/xlink",
sldUrl);

This should help:

XmlDocument xmlDocument = new XmlDocument();
XmlElement eOnlineResource =
xmlDocument.Cre ateElement("Onl ineResource");
XmlAttribute xlinkHref = xmlDocument.Cre ateAttribute("x link",
"href", "http://www.w3.org/1999/xlink");
xlinkHref.Value = "http://example.com/example";
eOnlineResource .SetAttributeNo de(xlinkHref);

For the attribute value you obviously want your sldUrl then instead of
the example.com URL the example shows.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 22 '06 #5

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

Similar topics

4
1789
by: eagle0Nine | last post by:
I'm fairly new at using XML XSL and XLink, and I was wondering how I could use the three to create a menu link to another page (i.e. a menu button "Contact Us" would link to a seperate contact page). I've tried implementing XLink, but I seem to be failing. If I use it properly, would the link show up on an XML file (the one I am viewing through XSLT) as a hyperlink to another site (like any <a href>?). This seems to be my major barrier....
1
2180
by: Bernd Oninger | last post by:
As far as I know one could use other xsd schemas with the import and the xlink feature. What are the differences (beside the syntax)? Bernd
0
1397
by: Gene Ellis | last post by:
Very simple question. If I have the XML file below: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="newspage.xsl"?> <newspage> <content>Click here for blah blah</content> </newspage> How can I use XLink to make an HTML hyperlink out of the "click here" text?
4
4002
by: Lance Dyas | last post by:
I have managed to get the xml to load using the xmlHTTPrequest... (inspite of premature readyState 4) the problem now arises in Safari alone... var thelink = node.getAttribute("xlink:href") Works in other browsers... except Safari, where it always returns null Any ideas?
2
1964
by: adMjb | last post by:
Hi Any help would be fantastic I have a simple problem but I cant work it out... DOHH...., this is my XML: <?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet type="text/css" href="BSI%20Test.css"?> <document xmlns:xlink="http://www.w3.org/1999/xlink"
4
2900
by: Martin | last post by:
Hello I'm trying to learn xlink/xpointer (with no success so far :-( I would like to produce the following output. AAAA BBBB CCCC AAAA
0
1536
by: ab.angadbhat | last post by:
hi, I have an element in the xml file which has xlink:href ="xyz.xml" as an attribute. I am using xpointer to point to only 2nd <Uelement of the xyz.xml file and so i am doing:- xlink:href ="xyz.xml#xpointer(//U) In my xslt file i am using
1
1660
by: kaye80 | last post by:
I have an XML and XSL document. I am trying to incorporate hyperlinks throughout the XML document. I have read many of the related posts on this and other forums but I can't seem to get it right. Please help! Do I have to declare the namespace in the XSL doc also as shown below or should I take it out? No matter what I do, nothing appears for the link tag in the browser. a piece of my xml DOC (using google for now as an easy example but...
0
2603
by: osin | last post by:
Hello everyone, I need to generate an XML file whose element would be an active link (triggering a PERL script). The only tool I've found which is capable of doing it is Xlink. The problem is that it doesn't work properly. My XML file is : <searchresult xmlns:xlink="http://www.w3.org/1999/xlink"> <account> <accountpoid xlink:type="simple" xlink:show="replace" xlink:href="http:/localhost/cgi-bin/sample12_copy.pl">16213</accountpoid>...
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
9480
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,...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
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
7500
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
5381
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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.