本文整理汇总了C#中System.Xml.XmlElement.getAttributeNS方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.getAttributeNS方法的具体用法?C# XmlElement.getAttributeNS怎么用?C# XmlElement.getAttributeNS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.getAttributeNS方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fromDOM
/*
****************************************************************************
* fromDOM()
****************************************************************************
*/
/**
* This method populates the obj from DOM. It does not keep a
* copy of the DOM around. Whitespace information is lost in this process.
*/
public void fromDOM(XmlElement oElem)
{
reset();
// get the id attribute
if (oElem.hasAttributeNS(null, Tags.ATTR_ID_CAP))
{
msXmlID = oElem.getAttributeNS(null, Tags.ATTR_ID_CAP);
}
if (oElem.hasAttributeNS(null, Tags.ATTR_ISSUEINSTANT))
{
msIssueInstant = oElem.getAttributeNS(null, Tags.ATTR_ISSUEINSTANT);
}
for (
XmlNode oChild = oElem.FirstChild; oChild != null;
oChild = oChild.NextSibling)
{
if (oChild.LocalName.Equals(Tags.TAG_ISSUER))
{
// only accept the first XRIAuthority
if (moIssuer == null)
{
moIssuer = new NameID((XmlElement) oChild);
}
}
else if (oChild.LocalName.Equals(Tags.TAG_SIGNATURE))
{
// only accept the first XRIAuthority
if (moSignature == null)
{
try
{
XmlDocument oDoc = new XmlDocument();
XmlElement oChildCopy =
(XmlElement) oDoc.ImportNode(oChild, true);
moSignature = new XMLSignature(oChildCopy, null);
}
catch (Exception oEx)
{
soLog.Warn(
"Caught exception while parsing Signature", oEx);
}
}
}
else if (oChild.LocalName.Equals(Tags.TAG_SUBJECT))
{
// only accept the first XRIAuthority
if (moSubject == null)
{
moSubject = new Subject((XmlElement) oChild);
}
}
else if (oChild.LocalName.Equals(Tags.TAG_CONDITIONS))
{
// only accept the first XRIAuthority
if (moConditions == null)
{
moConditions = new Conditions((XmlElement) oChild);
}
}
else if (oChild.LocalName.Equals(Tags.TAG_ATTRIBUTESTATEMENT))
{
// only accept the first XRIAuthority
if (moAttrStatement == null)
{
moAttrStatement = new AttributeStatement((XmlElement) oChild);
}
}
}
}
示例2: bestEffortSetIDAttr
/*
****************************************************************************
* bestEffortSetIDAttr()
****************************************************************************
*/
/**
* Makes a best effort at setting the ID attribute so that it can be looked
* up using XmlDocument::getElementsById
*/
public static void bestEffortSetIDAttr(
XmlElement oElem, string sNS, string sAttr)
{
// do nothing if there is nothing to do
if ((oElem == null) || (sAttr == null))
{
return;
}
// if we are using DOM3, use the setIdAttributeNode API
if (hasDOM3Support())
{
Attr oAttr = oElem.getAttributeNodeNS(sNS, sAttr);
// compiler-friendly way of doing setId as follows:
// oElem.setIdAttributeNode(oAttr, true);
try {
oElem.GetType().getMethod("setIdAttributeNode", new Class[] { oAttr.GetType(), Boolean.TYPE })
.invoke(oElem, new Object[] { oAttr, true });
}
/*
catch (IllegalArgumentException e) { }
catch (SecurityException e) { }
catch (IllegalAccessException e) { }
catch (InvocationTargetException e) { }
catch (NoSuchMethodException e) { }
*/
catch (Exception e) {
throw new RuntimeException("Exception caught while calling setIdAttributeNode: " + e);
}
if (!oAttr.isId()) {
throw new RuntimeException("attribute node is not of type Id even after calling setIdAttributeNode!");
}
return;
}
// if it is an XmlDocument, use the putIdentifier method
if (isXercesDocument(oElem.getOwnerDocument()))
{
string sAttrVal = oElem.getAttributeNS(sNS, sAttr);
((XmlDocument) oElem.getOwnerDocument()).putIdentifier(
sAttrVal, oElem);
return;
}
throw new RuntimeException(
"No known method to set a signable ID attribute. " +
"Try using a DOM3-compliant Parser or a DOM2 Xerces XmlDocument.");
}
示例3: fromDOM
//throws UriFormatException, ParseException
/**
* This method populates the obj from DOM. It does not keep a
* copy of the DOM around. Whitespace information is lost in this process.
*/
public void fromDOM(XmlElement oElem)
{
reset();
// get the id attribute
if (oElem.hasAttributeNS(Tags.NS_XML, Tags.ATTR_ID_LOW))
xmlID = oElem.getAttributeNS(Tags.NS_XML, Tags.ATTR_ID_LOW);
if (oElem.hasAttributeNS(Tags.NS_XML, Tags.ATTR_IDREF))
idRef = oElem.getAttributeNS(Tags.NS_XML, Tags.ATTR_IDREF);
if (oElem.hasAttributeNS(null, Tags.ATTR_XRD_VERSION))
version = oElem.getAttributeNS(null, Tags.ATTR_XRD_VERSION);
for (XmlElement oChild = (XmlElement)oElem.FirstChild; oChild != null; oChild = (XmlElement)oChild.NextSibling) {
string sChildName = oChild.LocalName ?? oChild.Name;
if (sChildName.Equals(Tags.TAG_TYPE)) {
XRDType t = new XRDType();
t.fromXML(oChild);
types.Add(t);
} else if (sChildName.Equals(Tags.TAG_QUERY)) {
Query q = new Query();
q.fromXML(oChild);
this.query = q;
} else if (sChildName.Equals(Tags.TAG_STATUS)) {
Status s = new Status();
s.fromXML(oChild);
this.status = s;
} else if (sChildName.Equals(Tags.TAG_SERVERSTATUS)) {
ServerStatus s = new ServerStatus();
s.fromXML(oChild);
this.serverStatus = s;
} else if (sChildName.Equals(Tags.TAG_EXPIRES)) {
// only accept the first Expires element and make sure it
expires = new Expires(XmlConvert.ToDateTime(oChild.FirstChild.Value));
} else if (sChildName.Equals(Tags.TAG_PROVIDERID)) {
ProviderID p = new ProviderID();
p.fromXML(oChild);
this.providerID = p;
} else if (sChildName.Equals(Tags.TAG_LOCALID)) {
addLocalID(new LocalID(oChild));
} else if (sChildName.Equals(Tags.TAG_EQUIVID)) {
equivIDs.Add(new EquivID(oChild));
} else if (sChildName.Equals(Tags.TAG_CANONICALID)) {
canonicalIDs.Add(new CanonicalID(oChild));
} else if (sChildName.Equals(Tags.TAG_CANONICALEQUIVID)) {
canonicalEquivID = new CanonicalEquivID();
canonicalEquivID.fromXML(oChild);
} else if (sChildName.Equals(Tags.TAG_REDIRECT)) {
Redirect _ref = new Redirect(oChild);
addRedirect(_ref);
} else if (sChildName.Equals(Tags.TAG_REF)) {
Ref _ref = new Ref(oChild);
addRef(_ref);
} else if (sChildName.Equals(Tags.TAG_SERVICE)) {
addService(new Service(oChild));
} else if (
(oChild.NamespaceURI != null) &&
oChild.NamespaceURI.Equals(Tags.NS_SAML) &&
(oChild.LocalName != null) &&
oChild.LocalName.Equals(Tags.TAG_ASSERTION)) {
samlAssertion = new Assertion(oChild);
}
// Added this code to support extensions in Authority XmlElement
else {
ArrayList oVector =
(ArrayList)moOtherChildrenVectorsMap[sChildName];
if (oVector == null) {
oVector = new ArrayList();
moOtherChildrenVectorsMap[sChildName] = oVector;
}
oVector.Add(oChild.CloneNode(true));
}
}
}
示例4: fromDOM
/*
****************************************************************************
* fromDOM()
****************************************************************************
*/
/**
* This method populates the XRD from DOM. It does not keep a
* copy of the DOM around. Whitespace information is lost in this process.
*/
public void fromDOM(XmlElement oElem)
{
reset();
// get the id attribute
if (oElem.hasAttributeNS(null, Tags.ATTR_NAME))
{
msName = oElem.getAttributeNS(null, Tags.ATTR_NAME);
}
for (
XmlNode oChild = oElem.FirstChild; oChild != null;
oChild = oChild.NextSibling)
{
if (oChild.LocalName.Equals(Tags.TAG_ATTRIBUTEVALUE))
{
// only accept the first element and make sure it
// is a text node
if (
(msValue.Equals("")) && (oChild.FirstChild != null) &&
(oChild.FirstChild.NodeType == XmlNode.TEXT_NODE))
{
msValue = oChild.FirstChild.getNodeValue();
}
}
}
}