xml-namespaces

Transform XML into a Map using groovy

陌路散爱 提交于 2020-01-25 08:12:24
问题 I have some XML that I want to transform into a Map. I used the middle way of transforming XML to JSON and then greating a map of the json: import org.json.XML import groovy.json.JsonSlurper Map parseXml(String input) { String json = XML.toJSONObject(input).toString() new JsonSlurper().parseText(json) } But when you have name spacing, it does not get removed. eg. <ns2:someObject xmlns:ns2="http://someLink"> <someOtherObject> <something>SOME_THING</something> </someOtherObject>

adding namespace and namespace prefix using dom4j

杀马特。学长 韩版系。学妹 提交于 2020-01-25 03:18:05
问题 i am updating one xml using dom4j as below. SAXReader reader = new SAXReader(); document = reader.read( xmlFileName ); but it removes all namespaces from the elements so wanna add manually but it does not work when i tried the following code. Element e1 = root.addElement("jmsProducer"); e1.addNamespace("AEService", "http://www.tibco.com/xmlns/aemeta/services/2002"); my xml looks like <AEService:jmsProducer objectType="endpoint.JMSPublisher" name="Pub1EndPoint"> <AEService:wireFormat>aeXml<

Xpath to select value of sibling attribute with namespace

梦想的初衷 提交于 2020-01-20 08:08:51
问题 I'm struggling to get an XPath defined to return the value of the uniqueappversionid from the following XML: <?xml version="1.0" encoding="UTF-8"?> <manifest package="air.com.vzw.Foo" android:versionCode="0" android:versionName="0.0.0" android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:label="FooAIR"> <meta-data android:name="autoOrients" android:value="true" /> <meta-data android:name="fullScreen" android:value="false" /> <meta

Xpath to select value of sibling attribute with namespace

夙愿已清 提交于 2020-01-20 08:07:59
问题 I'm struggling to get an XPath defined to return the value of the uniqueappversionid from the following XML: <?xml version="1.0" encoding="UTF-8"?> <manifest package="air.com.vzw.Foo" android:versionCode="0" android:versionName="0.0.0" android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:label="FooAIR"> <meta-data android:name="autoOrients" android:value="true" /> <meta-data android:name="fullScreen" android:value="false" /> <meta

Xpath to select value of sibling attribute with namespace

半世苍凉 提交于 2020-01-20 08:07:25
问题 I'm struggling to get an XPath defined to return the value of the uniqueappversionid from the following XML: <?xml version="1.0" encoding="UTF-8"?> <manifest package="air.com.vzw.Foo" android:versionCode="0" android:versionName="0.0.0" android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android"> <application android:label="FooAIR"> <meta-data android:name="autoOrients" android:value="true" /> <meta-data android:name="fullScreen" android:value="false" /> <meta

XML namespace on child element

早过忘川 提交于 2020-01-16 07:59:13
问题 I've got the following class structure: public class Child { ... } [XmlRoot("parent", Namespace="parentNamespace")] public class Parent { [XmlElement(Namespace="childNamespace")] public Child Child { get; set; } } The I try to serialize it using namespaces: namespaces.Add(string.Empty, "parentNamespace"); namespaces.Add("c", "childNamespace"); And I got the child namespace declared in parent element: <parent xmlns:c="childNamespace" xmlns="parentNamespace"> <c:Child ... /> </parent> But I

simplexml_load_string not parsing my XML string. Charset issue?

五迷三道 提交于 2020-01-15 10:44:14
问题 I'm using the following PHP code to read XML data from NOAA's tide reporting station API: $rawxml = file_get_contents( "http://opendap.co-ops.nos.noaa.gov/axis/webservices/activestations/" ."response.jsp?v=2&format=xml&Submit=Submit" ); $rawxml = utf8_encode($rawxml); $ob = simplexml_load_string($rawxml); var_dump($ob); Unfortunately, I end up with it displaying this: object(SimpleXMLElement)#246 (0) { } It looks to me like the XML is perfectly well-formed - why won't this parse? From looking

How to reference an attribute in xsd

南楼画角 提交于 2020-01-15 05:43:07
问题 I tried to define an attribute that could be referenced in subsequent element definitions. <xs:attribute name="ridref" type="xs:string"/> Later I use it like this: <xs:element name="coordRegRef"> <xs:complexType> <!--xs:attribute name="ridref" type="xs:string"/ this works but I want to use ref --> <xs:attribute ref="ridref" use="required"/> </xs:complexType> </xs:element> XSD compiles fine with xmllint xmllint --schema pc-ar.xsd pc-ar.xml But xmllint says pc-ar.xml:41: element coordRegRef:

How to reference an attribute in xsd

梦想的初衷 提交于 2020-01-15 05:43:07
问题 I tried to define an attribute that could be referenced in subsequent element definitions. <xs:attribute name="ridref" type="xs:string"/> Later I use it like this: <xs:element name="coordRegRef"> <xs:complexType> <!--xs:attribute name="ridref" type="xs:string"/ this works but I want to use ref --> <xs:attribute ref="ridref" use="required"/> </xs:complexType> </xs:element> XSD compiles fine with xmllint xmllint --schema pc-ar.xsd pc-ar.xml But xmllint says pc-ar.xml:41: element coordRegRef:

How can I add InnerXml without it being modified in any way?

℡╲_俬逩灬. 提交于 2020-01-14 03:00:07
问题 I'm trying to find a simple way to add XML to XML-with-xmlns without getting the xmlns="" nor having to specify the xmlns every time. I tried both XDocument and XmlDocument but couldn’t find a simple way. The closest I got was doing this: XmlDocument xml = new XmlDocument(); XmlNode docNode = xml.CreateXmlDeclaration("1.0", "UTF-8", null); xml.AppendChild(docNode); XmlElement root = xml.CreateElement("root", @"http://example.com"); xml.AppendChild(root); root.InnerXml = "<a>b</a>"; But what I