Hi I have a xml file that contains
<?xml version="1.0" encoding="utf-8"?>
<resources>
<iconback img1="iconback" />
<iconmask img1="iconmask" />
<iconupon img1="iconupon" />
<scale factor="0.7" />
</resources>
How can I change and save the img="iconback" outer text and Scale factor="0.7?
Everything I try fails with
Cannot set a value on node type 'Element'
Related
I have a SVG document defined as below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg width="210mm" height="297mm" xmlns="http://www.w3.org/2000/svg" dominant-baseline="hanging">
<text x="108.18mm" y="7.14mm" font-size="12pt" font-family="Times New Roman" font-weight="bold" font-style="italic">SVG Template to Test Various Styling</text>
<style>
text {
fill: gold;
stroke: maroon;
stroke-width: 2px;
}
</style>
</svg>
While this SVG gets Previewed in the browser as expected when I pass this on to a C# appilcation which is built to read svgs if throws an exception saying **`
The template's contents do not follow the schema
`** .
I have no Idea as to what is causing this as the browser seems to be rendering this as expected
Further the error also says :- The element 'svg' in namespace 'http://www.w3.org/2000/svg' has invalid child element 'style' in namespace 'http://www.w3.org/2000/svg'
Any idea that may help me ?
I have a shape as the background of my linear layout, that shape is a ring that is in sn XML file in drawable, I'm trying to find out how to change the color of this shape in my C# files, I'm working in Xamarin on Visual Studio for Mac
This is my code:
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/rng">
<shape
android:shape="ring"
android:innerRadius="150dp"
android:thickness="10dp"
android:useLevel="false">
<solid android:color="#ababf2" />
</shape>
</item>
</layer-list>
...
I have been having problems with incorporating a Progress Bar into my splash screen. I have an XML file called splash_setup,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background">
<bitmap
android:src="#drawable/splash"
android:tileMode="disabled"
android:gravity="top|center_horizontal" />
<ProgressBar
style="#android:style/Widget.ProgressBar.Small"
android:gravity="top|center_horizontal" />
</LinearLayout>
This file is used as background for 'splashTheme' (in Styles.XML) as following,
?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="splashTheme" parent="android:Theme">
<item name="android:windowBackground">#drawable/splash_setup</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
The splashTheme is used in splashActivity (the splash executes database initialisation and then finished),
[Activity(Label = "#string/appName", Theme = "#style/splashTheme",
MainLauncher = true, NoHistory = true)]
So to my problem... the splash_setup code runs fine without tags, but when they are in I get the following error,
android.content.res.Resources$NotFoundException: File res/drawable/splash_setup.xml from drawable resource ID #0x7f020002
Could anyone point out what I am doing wrong? Thanks!
What you have is a layout not a drawable. android:windowBackground attribute in style allows only drawable which may include shapes and/or layer lists. If you really wish to show a progressbar, then you need an activity.
The best way to explain my problem is by a example.
I have a Xml file with some elements in it. When I remove a element, I save the file again and this problem occurs:
Before save
<?xml version="1.0" encoding="utf-8"?>
<ElementTree>
<Elements1 />
<Elements2>
<Element Name="TestElement" ID="4efa7cc9-a89a-429b-81f4-b00cde729f24" />
</Elements2>
<Elements3 />
</ElementTree>
After save
<?xml version="1.0" encoding="utf-8"?>
<ElementTree>
<Elements1 />
<Elements2 />
<Elements3 />
</ElementTree>D="4efa7cc9-a89a-429b-81f4-b00cde729f24" />
</Elements2>
<Elements3 />
</ElementTree>
What I suspect it is doing: It keeps writing the text untill it has reached the end of the text to be saved and then it stops. It does not remove the text that is still writen in the file AFTER the last character in the stream.
How can I fix this?
Make sure you replace the existing file when opening it and you close the stream correctly.
I'm definitely missing something. I have an XML file that stores HTML snippets, as below:
<?xml version="1.0" encoding="utf-8"?>
<presentation>
<slide id="1" title="Test Slide 1">
<h1>This is test slide 1.</h1>
<p>Information on test slide.</p>
</slide>
<slide id="2" title="Test Slide 2">
<h2> This is test slide 2.</h2>
<p>Information on test slide.</p>
</slide>
<slide id="3" title="Test Slide 3">
<h3> This is test slide 3.</h3>
<p>Information on test slide.</p>
</slide>
</presentation>
I'm building a ASP.net form that allows me to edit the contents of the "slides" and then save my changes. In order to do that, first i find the appropriate slide by id. Then I remove all the contents of the slide with RemoveNodes(), and then attempt to write the new contents with WriteRaw(contents).
XDocument xmlDoc = XDocument.Load(filepath);
XElement slide = xmlDoc.Descendants("slide").First(el => el.Attribute("id").Value.Equals(id));
slide.RemoveNodes();
using (var writer = slide.CreateWriter())
{
// contents are retrieved from a TextBox
writer.WriteRaw(contents);
}
xmlDoc.Save(filepath);
The code runs without error. However, when I check the xml file, the < and > characters for the html tags have been converted to < and >.
...
<slide id="1" title="Test Slide 1"><h1>This is test slide 1.</h1>
<p>Information on test slide.</p>></slide>
...
I'm guessing that another object is escaping the characters in the background. SaveOptions.DisableFormatting doesn't change the behavior. Can anyone point me in the right direction?
Sorry, but XmlWriter.WriteRaw works on XmlWriters writing to a stream or file but not when populating objects in System.Xml or System.Xml.Linq.
Use slide.Add(XElement.Parse("<dummy>" + contents + "</dummy>").Nodes()) instead.