XPath contains(text(),’some string’) doesn’t work when used with node with more than one Text subnode

The <Comment> tag contains two text nodes and two <br> nodes as children. Your xpath expression was //*[contains(text(),’ABC’)] To break this down, * is a selector that matches any element (i.e. tag) — it returns a node-set. The [] are a conditional that operates on each individual node in that node set. It matches if … Read more

Center a button in a Linear layout

Center using a LinearLayout: <LinearLayout android:id=”@+id/LinearLayout1″ android:layout_width=”match_parent” android:layout_height=”match_parent” android:gravity=”center” android:orientation=”vertical” > <ImageButton android:id=”@+id/btnFindMe” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”@drawable/findme” /> </LinearLayout>

Getting attribute using XPath

How could I get the value of lang (where lang=eng in book title), for the first element? Use: /*/book[1]/title/@lang This means: Select the lang attribute of the title element that is a child of the first book child of the top element of the XML document. To get just the string value of this attribute … Read more

POST XML file using cURL command line

If that question is connected to your other Hudson questions use the command they provide. This way with XML from the command line: $ curl -X POST -d ‘<run>…</run>’ \ http://user:pass@myhost:myport/path/of/url You need to change it a little bit to read from a file: $ curl -X POST -d @myfilename http://user:pass@myhost:myport/path/of/url Read the manpage. following … Read more

What does “xmlns” in XML mean?

It means XML namespace. Basically, every element (or attribute) in XML belongs to a namespace, a way of “qualifying” the name of the element. Imagine you and I both invent our own XML. You invent XML to describe people, I invent mine to describe cities. Both of us include an element called name. Yours refers … Read more

Declaring a custom android UI element using XML

The Android Developer Guide has a section called Building Custom Components. Unfortunately, the discussion of XML attributes only covers declaring the control inside the layout file and not actually handling the values inside the class initialisation. The steps are as follows: 1. Declare attributes in values\attrs.xml <?xml version=”1.0″ encoding=”utf-8″?> <resources> <declare-styleable name=”MyCustomView”> <attr name=”android:text”/> <attr … Read more

What’s the difference between text/xml vs application/xml for webservice response

From the RFC (3023), under section 3, XML Media Types: If an XML document — that is, the unprocessed, source XML document — is readable by casual users, text/xml is preferable to application/xml. MIME user agents (and web user agents) that do not have explicit support for text/xml will treat it as text/plain, for example, … Read more